// AGUNAWAN
// CE-6A
// 1205112001
// J2ME APLICATION
package Reservasi_Hotel;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
import java.lang.Math;
import java.util.Date;
import javax.microedition.midlet.*;
public class Reservasi_Hotel extends MIDlet implements CommandListener {
private static final String kReservation = "Reservation";
private static final String kJKamar = "Jenis Kamar";
private static final String kOpsiTambahan = "Opsi Tambahan";
private static final String kSummary = "Summary";
private static final String kExit = "Exit";
private Display mDisplay;
private List lJKList;
private Form fReservation, fJKamar, fOT, fSummary;
private Command mNextCommand = new Command("Next", Command.OK, 0);
private Command mExitCommand = new Command("Exit", Command.EXIT, 0);
private Command mBackCommand = new Command("Back", Command.BACK, 0);
private DateField toCIn = new DateField("Check In :", DateField.DATE);
private DateField toCOut = new DateField("Check Out :", DateField.DATE);
private TextField toJumOrg = new TextField("Jumlah Orang :", "", 5, TextField.NUMERIC);
private TextField toNama = new TextField("Nama :", "", 50, TextField.ANY);
private TextField toPhone = new TextField("Phone :", "", 12, TextField.PHONENUMBER);
private TextField toEmail = new TextField("Email :", "", 100, TextField.EMAILADDR);
private ChoiceGroup toView = new ChoiceGroup("Choose The View", Choice.POPUP);
private TextField toExtraBed = new TextField("Extra Bed :", "", 5, TextField.NUMERIC);
private ChoiceGroup toLantai = new ChoiceGroup("Choose The Floor", Choice.POPUP);
private TextField toLainnya = new TextField("More :", "", 500, TextField.ANY);
private Date toCin1;
private StringItem tiNama, tiPhone, tiEmail, tiCIn, tiCOut, tiJumOrg, tiJK, tiEB, tiV, tiLan, tiEtc;
private String sNama, sPhone, sEmail, sCIn, sCOut, sJumOrg, sJK, sEB, sV, sLan, sEtc = null;
public void startApp() {
if (mDisplay == null) {
fReservation = new Form("Enter your Reservation");
fReservation.append(toNama);
fReservation.append(toPhone);
fReservation.append(toEmail);
fReservation.append(toCIn);
fReservation.append(toCOut);
fReservation.append(toJumOrg);
fReservation.addCommand(mNextCommand);
fReservation.addCommand(mExitCommand);
fReservation.setCommandListener(this);
fOT = new Form("Fill This Form If You Want More");
fOT.append(toExtraBed);
toView.append("City", null);
toView.append("Village", null);
toView.append("Lake", null);
toView.append("Garden", null);
fOT.append(toView);
for (int l = 0; l <= 30; l++) {
String m = Integer.toString(l);
toLantai.append(m, null);
}
fOT.append(toLantai);
fOT.append(toLainnya);
fOT.addCommand(mNextCommand);
fOT.addCommand(mExitCommand);
fOT.setCommandListener(this);
JKList();
tiNama = new StringItem("nama : ", null);
tiPhone = new StringItem("nim : ", null);
tiEmail = new StringItem("alamat : ", null);
tiCIn = new StringItem("tempat tanggal lahir : ", null);
tiCOut = new StringItem("D/M/Y : ", null);
tiJumOrg = new StringItem("Study : ", null);
tiJK = new StringItem("Room Type : ", null);
tiEB = new StringItem("Extra Bed : ", null);
tiV = new StringItem("View : ", null);
tiLan = new StringItem("Floor :", null);
tiEtc = new StringItem("More :", null);
fSummary = new Form("Your Reservation");
fSummary.append(tiNama);
fSummary.append(tiPhone);
fSummary.append(tiEmail);
fSummary.append(tiCIn);
fSummary.append(tiCOut);
fSummary.append(tiJumOrg);
fSummary.append(tiEB);
fSummary.append(tiV);
fSummary.append(tiLan);
fSummary.append(tiEtc);
fSummary.addCommand(mNextCommand);
fSummary.addCommand(mExitCommand);
fSummary.setCommandListener(this);
mDisplay = Display.getDisplay(this);
}
mDisplay.setCurrent(fReservation);
}
public void JKList() {
lJKList = new List("Choose Your Rooms Type", List.MULTIPLE);
lJKList.append("President Suit", null);
lJKList.append("Extra Deluxe", null);
lJKList.append("Deluxe", null);
lJKList.append("Standard", null);
lJKList.addCommand(mNextCommand);
lJKList.addCommand(mBackCommand);
lJKList.setCommandListener(this);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
if (c == mExitCommand) {
destroyApp(true);
notifyDestroyed();
} else if (c == mNextCommand) {
if (d == fReservation) {
mDisplay.setCurrent(lJKList);
int actionIndex = lJKList.getSelectedIndex();
if (actionIndex < 0) {
return;
}
else if (actionIndex >= 0 && actionIndex <= 3) {
for (int i = 0; i < actionIndex; i++) {
String alert = "Anda memilih :" + lJKList.getString(actionIndex);
lJKList.append(alert, null);
JKList();
}
}
} else if (d == lJKList) {
mDisplay.setCurrent(fOT);
} else {
sNama = toNama.getString();
sPhone = toPhone.getString();
sEmail = toEmail.getString();
sCIn = String.valueOf(toCIn);
sCOut = String.valueOf(toCOut);
sJumOrg = toJumOrg.getString();
sJK = lJKList.getString(lJKList.getSelectedIndex());
sEB = toExtraBed.getString();
sV = toView.getString(toView.getSelectedIndex());
sLan = toLantai.getString(toLantai.getSelectedIndex());
sEtc = toLainnya.getString();
tiNama.setText(sNama);
tiPhone.setText(sPhone);
tiEmail.setText(sEmail);
tiCIn.setText(sCIn);
tiCOut.setText(sCOut);
tiJumOrg.setText(sJumOrg);
tiJK.setText(sJK);
tiEB.setText(sEB);
tiV.setText(sV);
tiLan.setText(sLan);
tiEtc.setText(sEtc);
mDisplay.setCurrent(fSummary);
}
}
}
}
Sabtu, 18 April 2015
Sabtu, 04 April 2015
Tugas Mobile Aplication
// AGUNAWAN CE-6A 1205112001
package MobileApplication2;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class MobileApplication2 extends MIDlet implements CommandListener{
private Command exit;
private Command back;
private Command save;
private Command done;
private Command opening;
private Command comment;
private Form fm;
private List lst;
private TextBox tb;
private Display d;
//contructor
public MobileApplication2(){
d = Display.getDisplay(this);
fm = new Form("TAMPILAN AWAL = AGUNAWAN CE-6A");
tb = new TextBox("Tulis Komentar", null, 500, 0);
lst = new List("Pesan pembuka", List.IMPLICIT);
lst.append("SELAMAT DATANG DI POLITEKNIK NEGERI MEDAN", null);
exit = new Command("Exit", Command.EXIT,1);
back = new Command("Back", Command.BACK,1);
save = new Command("save", Command.OK,1);
done = new Command("done", Command.OK,1);
comment = new Command("Tulis Komentar", Command.OK, 2);
opening = new Command("Pesan pembuka", Command.OK, 1);
fm.addCommand(exit);
fm.addCommand(comment);
fm.addCommand(opening);
tb.addCommand(back);
tb.addCommand(save);
lst.addCommand(back);
lst.addCommand(done);
fm.setCommandListener(this);
tb.setCommandListener(this);
lst.setCommandListener(this);
}
public void startApp() {
d.setCurrent(fm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable dd) {
if(c == exit){
destroyApp(false);
notifyDestroyed();
}
else if(c == opening){
Alert al = new Alert("Pesan pembuka");
al.setString("Mohon tunggu sebentar untuk melihat pesan pembuka");
d.setCurrent(al, lst);
}
else if(c == comment){
Alert al = new Alert("Simpan komentar");
al.setString("Mohon tunggu untuk menulis komentar");
al.setType(AlertType.INFO);
d.setCurrent(al, tb);
}
else if(c == back){
d.setCurrent(fm);
}
else if(c == save){
Alert al = new Alert("Perhatian");
al.setString("Komentar telah berhasil disimpan");
al.setType(AlertType.INFO);
d.setCurrent(al, fm);
}
else if(c == done){
Alert al = new Alert("Loading");
al.setType(AlertType.INFO);
d.setCurrent(al, fm);
}
}
}
Dibawah ini adalah tampilan aplikasi yang sudah dijalankan
1. Tampilan awal.
package MobileApplication2;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;
public class MobileApplication2 extends MIDlet implements CommandListener{
private Command exit;
private Command back;
private Command save;
private Command done;
private Command opening;
private Command comment;
private Form fm;
private List lst;
private TextBox tb;
private Display d;
//contructor
public MobileApplication2(){
d = Display.getDisplay(this);
fm = new Form("TAMPILAN AWAL = AGUNAWAN CE-6A");
tb = new TextBox("Tulis Komentar", null, 500, 0);
lst = new List("Pesan pembuka", List.IMPLICIT);
lst.append("SELAMAT DATANG DI POLITEKNIK NEGERI MEDAN", null);
exit = new Command("Exit", Command.EXIT,1);
back = new Command("Back", Command.BACK,1);
save = new Command("save", Command.OK,1);
done = new Command("done", Command.OK,1);
comment = new Command("Tulis Komentar", Command.OK, 2);
opening = new Command("Pesan pembuka", Command.OK, 1);
fm.addCommand(exit);
fm.addCommand(comment);
fm.addCommand(opening);
tb.addCommand(back);
tb.addCommand(save);
lst.addCommand(back);
lst.addCommand(done);
fm.setCommandListener(this);
tb.setCommandListener(this);
lst.setCommandListener(this);
}
public void startApp() {
d.setCurrent(fm);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable dd) {
if(c == exit){
destroyApp(false);
notifyDestroyed();
}
else if(c == opening){
Alert al = new Alert("Pesan pembuka");
al.setString("Mohon tunggu sebentar untuk melihat pesan pembuka");
d.setCurrent(al, lst);
}
else if(c == comment){
Alert al = new Alert("Simpan komentar");
al.setString("Mohon tunggu untuk menulis komentar");
al.setType(AlertType.INFO);
d.setCurrent(al, tb);
}
else if(c == back){
d.setCurrent(fm);
}
else if(c == save){
Alert al = new Alert("Perhatian");
al.setString("Komentar telah berhasil disimpan");
al.setType(AlertType.INFO);
d.setCurrent(al, fm);
}
else if(c == done){
Alert al = new Alert("Loading");
al.setType(AlertType.INFO);
d.setCurrent(al, fm);
}
}
}
Dibawah ini adalah tampilan aplikasi yang sudah dijalankan
1. Tampilan awal.
2. Tampilan Pesan pembuka.
3. Tampilan Komentar.
Langganan:
Postingan (Atom)