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
        }
    }
}