Pages

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

0 comments:

Post a Comment