Pages

Gedung Pusat Administrasi

POLITEKNIK NEGERI MEDAN

COMPUTER ENGINEERING

POLITEKNIK NEGERI MEDAN

Pembukaan Kegiatan P2MB

POLITEKNIK NEGERI MEDAN

POLITEKNIK NEGERI MEDAN

BAJU COMPUTER ENGINEERING

POLITEKNIK NEGERI MEDAN

Thursday, April 23, 2015

Tugas Pemrograman Mobile II

package sukri.arnanda.lubis;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
/**
* @author ArnandaSukriLubis
*/

public class LatihanDua extends MIDlet implements CommandListener
{
public TextField checkIn;
public TextField checkOut;
public TextField jumlahDewasa;
public TextField jumlahAnak;
public TextField biayaKamar;
public TextField biayaTambahan;
public TextField totalBiaya;
public Command mExit;
public Command mHome;
public Command mTipeKamar;
public Command mPermintaan;
public Command mSummary;
public Command mPembayaran;
public Command mSubmit;
public Command mSimpan;
public List list;
public Form home;
String a;
String b;
String e;
String f;
public void startApp()
{
home = new Form(“Home”);
checkIn = new TextField(“Tanggal Check In:”, “”, 20, TextField.ANY);
checkOut = new TextField(“Tanggal Check Out:”, “”, 20, TextField.ANY);
jumlahDewasa = new TextField(“Jumlah Dewasa:”, “”, 20, TextField.ANY);
jumlahAnak = new TextField(“Jumlah Anak-Anak:”, “”, 20, TextField.ANY);
mExit = new Command(“Exit”, Command.EXIT, 0);
mSubmit = new Command(“Submit”, Command.OK, 1);
mSubmit = new Command(“Submit”, Command.OK, 6);
mTipeKamar = new Command(“Tipe Kamar”, Command.OK, 2);
mPermintaan = new Command(“Permintaan”, Command.OK, 3);
mSummary = new Command(“Summary”, Command.OK, 4);
mPembayaran = new Command(“Pembayaran”, Command.OK, 5);
home.addCommand(mExit);
home.addCommand(mSimpan);
home.addCommand(mTipeKamar);
home.addCommand(mPermintaan);
home.addCommand(mSummary);
home.addCommand(mPembayaran);
home.append(checkIn);
home.append(checkOut);
home.append(jumlahDewasa);
home.append(jumlahAnak);
home.setCommandListener(this);
Display.getDisplay(this).setCurrent(home);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c, Displayable d)
{
if (c == mExit)
{
destroyApp(true);
notifyDestroyed();
}
if (c == mTipeKamar)
{
list = new List(“Pilih Kamar”, List.MULTIPLE);
mExit = new Command(“Exit”, Command.EXIT, 0);
mSubmit = new Command(“Submit”, Command.OK, 1);
mTipeKamar = new Command(“Tipe Kamar”, Command.OK, 2);
mPermintaan = new Command(“Permintaan”, Command.OK, 3);
mSummary = new Command(“Summary”, Command.OK, 4);
mPembayaran = new Command(“Pembayaran”, Command.OK, 5);
list.addCommand(mExit);
list.addCommand(mSubmit);
list.addCommand(mPermintaan);
list.addCommand(mSummary);
list.addCommand(mPembayaran);
list.append(“President Suite”, null);
list.append(“Super Deluxe”, null);
list.append(“Deluxe”, null);
list.append(“Standart”, null);
list.setCommandListener(this);
Display.getDisplay(this).setCurrent(list);
}
if (c == mPermintaan)
{
list = new List(“Pilih Tambahan”, List.MULTIPLE);
mExit = new Command(“Exit”, Command.EXIT, 0);
mSubmit = new Command(“Submit”, Command.OK, 1);
mTipeKamar = new Command(“Tipe Kamar”, Command.OK, 2);
mPermintaan = new Command(“Permintaan”, Command.OK, 3);
mSummary = new Command(“Summary”, Command.OK, 4);
mPembayaran = new Command(“Pembayaran”, Command.OK, 5);
list.addCommand(mExit);
list.addCommand(mSubmit);
list.addCommand(mTipeKamar);
list.addCommand(mPermintaan);
list.addCommand(mSummary);
list.addCommand(mPembayaran);
list.append(“Jendela menghadap pemandangan”, null);
list.append(“Ruangan dengan balkon”, null);
list.append(“Kamar di lantai bawah”, null);
list.append(“Kamar di lantai atas”, null);
list.append(“Ekstra bed”, null);
list.append(“Tambahan handuk dan sendal”, null);
list.setCommandListener(this);
Display.getDisplay(this).setCurrent(list);
}
if (c == mSummary)
{
Form sum = new Form(“Summary”);
biayaKamar = new TextField(“Biaya kamar:”, “Rp 3.250.000″, 20, TextField.UNEDITABLE);
biayaTambahan = new TextField(“Biaya tambahan:”, “Rp 1.500.000″, 20, TextField.UNEDITABLE);
totalBiaya = new TextField(“Total Biaya:”, “Rp 4.550.000″, 20, TextField.UNEDITABLE);
mExit = new Command(“Exit”, Command.EXIT, 0);
mSubmit = new Command(“Submit”, Command.OK, 1);
mTipeKamar = new Command(“Tipe Kamar”, Command.OK, 2);
mPermintaan = new Command(“Permintaan”, Command.OK, 3);
mSummary = new Command(“Summary”, Command.OK, 4);
mPembayaran = new Command(“Pembayaran”, Command.OK, 5);
sum.addCommand(mExit);
sum.addCommand(mTipeKamar);
sum.addCommand(mPermintaan);
sum.addCommand(mPembayaran);
sum.append(biayaKamar);
sum.append(biayaTambahan);
sum.append(totalBiaya);
sum.append(jumlahAnak);
sum.setCommandListener(this);
Display.getDisplay(this).setCurrent(sum);
}
if (c == mPembayaran)
{
Form pembayaran = new Form(“Pembayaran”);
biayaKamar = new TextField(“Silahkan transfer biaya ke rekening berikut:”, “119-123.123.123″, 20, TextField.UNEDITABLE);
biayaTambahan = new TextField(“NB:”, “Biaya sudah harus ditransfer paling lambat 4 jam sebelum kunjungan”, 20, TextField.UNEDITABLE);
mExit = new Command(“Exit”, Command.EXIT, 0);
mTipeKamar = new Command(“Tipe Kamar”, Command.OK, 2);
mPermintaan = new Command(“Permintaan”, Command.OK, 3);
mSummary = new Command(“Summary”, Command.OK, 4);
mPembayaran = new Command(“Pembayaran”, Command.OK, 5);
pembayaran.addCommand(mExit);
pembayaran.addCommand(mTipeKamar);
pembayaran.addCommand(mPermintaan);
pembayaran.append(biayaKamar);
pembayaran.append(biayaTambahan);
pembayaran.append(totalBiaya);
pembayaran.append(jumlahAnak);
pembayaran.setCommandListener(this);
Display.getDisplay(this).setCurrent(pembayaran);
}
if (c == mSubmit)
{
boolean choice[] = new boolean[list.size()];
StringBuffer message = new StringBuffer();
list.getSelectedFlags(choice);
for (int i = 0; i < choice.length; i++)
{
if (choice[i])
{
message.append(list.getString(i));
message.append(” “);
}
}
Alert alert = new Alert(“Pilihan : “, message.toString(), null, null);
alert.setTimeout(1000);
alert.setType(AlertType.INFO);
Display.getDisplay(this).setCurrent(alert);
list.removeCommand(mSubmit);
}
if (c == mSimpan)
{
boolean choice[] = new boolean[list.size()];
StringBuffer message = new StringBuffer();
a = cekIn.getString();
b = cekOut.getString();
e = jumlahDewasa.getString();
f = jumlahAnak.getString();
Alert alert = new Alert(“Isian : “);
alert.setString(a);
alert.setString(b);
alert.setString(e);
alert.setString(f);
alert.setTimeout(1000);
alert.setType(AlertType.INFO);
Display.getDisplay(this).setCurrent(alert);
}
}
}

Saturday, April 4, 2015

EVENT HANDLER

 Menampilkan list pada menu mobile dengan event Handler
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mobileapplication1;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class Midlet extends MIDlet implements CommandListener {

    Display display;
    Command exitCommand = new Command("Exit", Command.EXIT, 1);
    Command Menu = new Command ("Menu", Command.SCREEN,2);
    Command hal1 = new Command ("hal.1", Command.SCREEN,3);
    Command hal2 = new Command ("hal.2", Command.SCREEN,4);
    Command hal3 = new Command ("hal.3", Command.SCREEN,5);
    Alert helloAlert;
    Alert page1;

    public Midlet() {
        helloAlert = new Alert("Selamat datang dipoliteknik negeri medan", "Welcome", null, AlertType.INFO);
        helloAlert.setTimeout(Alert.FOREVER);
        helloAlert.addCommand(exitCommand);
        helloAlert.addCommand(Menu);
        helloAlert.addCommand(hal1);
        helloAlert.addCommand(hal2);
        helloAlert.addCommand(hal3);
        helloAlert.setCommandListener(this);
       
        page1 = new Alert ("ini halaman 1", "page 1", null, AlertType.INFO);
        page1.setTimeout(Alert.FOREVER);
        page1.addCommand(exitCommand);
        page1.setCommandListener(this);
    }

    public void startApp() {
        if (display == null) {
            display = Display.getDisplay(this);
        }
        display.setCurrent(helloAlert);
       
        //if (Menu == hal1){
         //   display = Display.getDisplay(this);
      //  }
        //display.setCurrent(page1);
       
    }
       

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == exitCommand) {
            destroyApp(true);
            notifyDestroyed(); // Exit
        }
    }
}

Sunday, June 2, 2013

Inheritance

Inheritance: A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class).
Polimorphysm: the ability of an object to take on many forms. In programming languages polymorphism is the capability of an action or method to do different things based on the object that it is acting upon. This is the third basic principle of object oriented programming. The three types of polymorphism are: ad-hoc (overloading and overriding), parametric (generics) and dynamic method binding.
Extends : is used to carry out the reduction of a class.
Abstraction: Abstraction refers to the ability to make a class abstract in OOP. An abstract class is one that cannot be instantiated. All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. You just cannot create an instance of the abstract class.
Method Overloading: a function means that you have multiple functions with the same name, but different signatures. The signature of a function is its return type and number/types of parameters.
Method Overriding: a method in the child class having the same name, same number of parameters and the same access specifier as in it’s parent then we can say that we are doing method overriding.
  • The example of Polimorphsm :    Bird myBird = null;
                                                                                    myBird = new Bird (7);
                                                                                     myBird.beak();
                                                                                    System.out.println ("");
  • The example in constractor :     public Bird (int v)
                                                   {                                         
                                                                                                    super ();
                                                                                                    this.flyVelocity = v;
                                                          System.out.println("This Bird flyVelocity is " +flyVelocity);
                                                          }
               

Tuesday, May 7, 2013

CALCULATOR

Calculator -- Arnanda Sukri Lubis

Wednesday, November 7, 2012

SUMMARY OCTOBER 18

SUMMARY OCTOBER 18
Inheritance: A class that is derived from another class is called a subclass (also a derived class, extended class, or child class). The class from which the subclass is derived is called a superclass (also a base class or a parent class).
Polimorphsm: the ability of an object to take on many forms. In programming languages polymorphism is the capability of an action or method to do different things based on the object that it is acting upon. This is the third basic principle of object oriented programming. The three types of polymorphism are: ad-hoc (overloading and overriding), parametric (generics) and dynamic method binding.
Extends : is used to carry out the reduction of a class.
Abstraction: Abstraction refers to the ability to make a class abstract in OOP. An abstract class is one that cannot be instantiated. All other functionality of the class still exists, and its fields, methods, and constructors are all accessed in the same manner. You just cannot create an instance of the abstract class.
Method Overloading: a function means that you have multiple functions with the same name, but different signatures. The signature of a function is its return type and number/types of parameters.
Method Overriding: a method in the child class having the same name, same number of parameters and the same access specifier as in it’s parent then we can say that we are doing method overriding.   
The example of Polimorphsm:    Bird myBird = null;
                                                                   myBird = new Bird (7);
                                                                   myBird.beak();
                                                                   System.out.println ("");
   
The example in constractor :     public Bird (int v)
                                                   {                                         
                                                                                                    super ();
                                                                                                    this.flyVelocity = v;
                                                          System.out.println("This Bird flyVelocity is " +flyVelocity);
                                                          }
               

Friday, October 5, 2012

OBJECT ORIENTED PROGRAMMING






From Addison Wesley – The Essence Of Object Oriented Programming With Java and UML


ü   Object Orientation is a significantly different way of thinking about solving problems and developing software solutions.
ü An Object-Oriented System is one that has been designed using abstraction with objects, encapsulated classes, communication via messages, object lifetime, class hierarchies, and polymorphism.
ü         An object represents an instance of a real or abstract thing.
ü   Encapsulation is enforced by having the definitions for attributes and methods inside a class definition.
ü   The attributes of  a class are defined by the declaration of  variables of  various types such as int or boolean.
ü     A Java class includes the definitions of  the methods used to implement the behaviors of  the class.
ü        The method definitions are integral parts of the class definition.
ü     A class is the definition of the attributes and methods needed to model a related group of objects.
ü  Classes can be organized into hierarchies. Association is a relationship between classes. Aggregation and composition represent whole/part relationships. Inheritance represents generalization/specialization.
ü   The interaction can be between objects of the same class, or objects of different classes. This interaction is handled  by sending messages (in Java, this is done by calling methods) to other objects to pass information or request action.
ü  Object Lifetime. The time an object exists - from its instantiation in its constructor until the object no longer exists and has been finalized by the Java garbage collector.
ü  Inheritance allows subclasses to selectively derive the properties of a superclass.
ü  Identity The characteristics or state of an object that allows it to be distinguished from other objects.
ü      Polymorphism is a characteristic of inheritance that ensures that instances of such subclasses behave correctly.
ü   Polymorphism goes hand in hand with inheritance, and means the right methods are used for individual objects in a derived class.
An understanding of how objects are created and implemented can make it easier to write good OO programs.
ü           There are four level visibility of methods.
ü Public Visibility. Public attributes and operations are visible to the whole world. Any other class can access the public items of a class.
ü Private Visibility. Private attributes and operations are visible only to members of the given class.
ü Protected Visibility. Protected attributes and operations are visible to the class and its subclasses.
ü  Friend Visibility. Friend attributes and operations are visible to a specified set of other classes. In Java, the package is used to define friend visibility. In C++, the friend specifier is used.
ü Just as any other specialized discipline, object-orientation has its own vocabulary.