Rabu, 29 April 2015

Perbaikan Tugas Pemesanan Hotel (Ummi Thaharani Lubis, IS-6B)

Diposting oleh Borkat Lubis di 18.06
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lubis;

import javax.microedition.midlet.*;
import java.util.Date;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class reservasiMidlet extends MIDlet implements CommandListener {

    Display dis;
    Command tipeCommand = new Command("Next", Command.OK, 1);
    Command opsiCommand = new Command("Next", Command.OK, 1);
    Command reviewCommand = new Command("Review", Command.OK, 1);
    Command backreservasiCommand = new Command("Back", Command.OK, 1);
    Command backtipeCommand = new Command("Back", Command.OK, 1);
    Command exitCommand = new Command("Exit", Command.EXIT, 1);
    private static final String kTipe = "Tipe";
    private static final String kOpsi = "Fasilitas Lain";
    TextField txtNama, txtJumlah;
    DateField dCheckIn, dCheckOut;
    StringItem Nama, CheckIn, CheckOut, Jumlah, Tipe, Opsi;
    private Display mDisplay;
    private List mTipeList, mOpsiList;
    Form reservasiForm, reviewForm = null;
    Alert helloAlert;

    public reservasiMidlet() {
        super();
        reservasiForm = new Form("Reservasi Hotel");
        txtNama = new TextField("Nama Pemesan :", "", 20, TextField.ANY);
        reservasiForm.append(txtNama);
        dCheckIn = new DateField("Check - In :", DateField.DATE);
        reservasiForm.append(dCheckIn);
        dCheckOut = new DateField("Check - Out", DateField.DATE);
        reservasiForm.append(dCheckOut);
        txtJumlah = new TextField("Jumlah Orang :  ", "", 20, TextField.ANY);
        reservasiForm.append(txtJumlah);
        reservasiForm.addCommand(tipeCommand);
        reservasiForm.addCommand(exitCommand);
        reservasiForm.setCommandListener(this);

        mTipeList = new List("Pilih Tipe Kamar", List.MULTIPLE);
        mTipeList.append("President Suite", null);
        mTipeList.append("Extra Deluxe", null);
        mTipeList.append("Deluxe", null);
        mTipeList.append("Standard", null);
        mTipeList.setCommandListener(this);
        mTipeList.addCommand(opsiCommand);
        mTipeList.addCommand(exitCommand);
        mTipeList.setCommandListener(this);

        mOpsiList = new List("Other Facility", List.MULTIPLE);
        mOpsiList.append("Room Service", null);
        mOpsiList.append("Meeting Room", null);
        mOpsiList.append("Transportation Service", null);
        mOpsiList.append("Laundry And Dry Cleaning", null);
        mOpsiList.addCommand(backreservasiCommand);
        mOpsiList.addCommand(reviewCommand);
        mOpsiList.setCommandListener(this);

        reviewForm = new Form("Review");
        Nama = new StringItem("Nama Pemesan : ", "");
        CheckIn = new StringItem("Check - In :", "");
        CheckOut = new StringItem("Check - Out :", "");
        Jumlah = new StringItem("Jumlah Orang :", "");
        Tipe = new StringItem("Tipe Kamar :", "");
        Opsi = new StringItem("Fasilitas Lain :", "");

        reviewForm.append(Nama);
        reviewForm.append(CheckIn);
        reviewForm.append(CheckOut);
        reviewForm.append(Jumlah);
        reviewForm.append(Tipe);
        reviewForm.append(Opsi);
        reviewForm.addCommand(backtipeCommand);
        reviewForm.addCommand(exitCommand);
        reviewForm.setCommandListener(this);

    }

    public void startApp() {
        if (dis == null) {
            dis = Display.getDisplay(this);
        }

        dis.setCurrent(reservasiForm);

    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == exitCommand) {
            destroyApp(true);
            notifyDestroyed(); //Exit
        } else if (c == backreservasiCommand) {
            dis.setCurrent(reservasiForm);
        } else if (c == backtipeCommand) {
            dis.setCurrent(mTipeList);
        } else if (c == tipeCommand) {
            dis.setCurrent(mTipeList);
            if (c == List.SELECT_COMMAND && d == mTipeList) {
                int actionIndex = mTipeList.getSelectedIndex();
                if (actionIndex < 0) {
                    return;
                }
                String action = mTipeList.getString(actionIndex);
                if (action.equals(kTipe)) {
                    mDisplay.setCurrent(mTipeList);
                }
            }
        } else if (c == opsiCommand) {
            dis.setCurrent(mOpsiList);
            if (c == List.SELECT_COMMAND && d == mOpsiList) {
                int actionIndex = mOpsiList.getSelectedIndex();
                if (actionIndex < 0) {
                    return;
                }
                String action = mOpsiList.getString(actionIndex);
                if (action.equals(kOpsi)) {
                    mDisplay.setCurrent(mOpsiList);
                }
            }
        } else if (c == reviewCommand) {
            try {
                Nama.setText(txtNama.getString());
                CheckIn.setText(dCheckIn.getDate().toString());
                CheckOut.setText(dCheckOut.getDate().toString());
                Jumlah.setText(txtJumlah.getString());

                if (mTipeList.isSelected(0)) {
                    Tipe.setText("President Suite");
                } else if (mTipeList.isSelected(1)) {
                    Tipe.setText("Extra Deluxe");
                } else if (mTipeList.isSelected(2)) {
                    Tipe.setText("Deluxe");
                } else if (mTipeList.isSelected(3)) {
                    Tipe.setText("Standard");
                } else if (mTipeList.isSelected(0) && (mTipeList.isSelected(1))) {
                    Tipe.setText("President Suite \nExtra Deluxe");
                } else if (mTipeList.isSelected(0) && (mTipeList.isSelected(2))) {
                    Tipe.setText("President Suite \nDeluxe");
                } else if (mTipeList.isSelected(0) && (mTipeList.isSelected(3))) {
                    Tipe.setText("President Suite \nStandard");
                } else if (mTipeList.isSelected(1) && (mTipeList.isSelected(2))) {
                    Tipe.setText("Extra Deluxe \nDeluxe");
                } else if (mTipeList.isSelected(1) && (mTipeList.isSelected(3))) {
                    Tipe.setText("Extra Deluxe \nStandard");
                } else if (mTipeList.isSelected(2) && (mTipeList.isSelected(3))) {
                    Tipe.setText("Extra Deluxe \nStandard");
                } else if (mTipeList.isSelected(0) && (mTipeList.isSelected(1)) && (mTipeList.isSelected(2))) {
                    Tipe.setText("President Suite \nExtra Deluxe \nDeluxe");
                } else if (mTipeList.isSelected(0) && (mTipeList.isSelected(1)) && (mTipeList.isSelected(3))) {
                    Tipe.setText("President Suite \nExtra Deluxe \nStandard");
                } else if (mTipeList.isSelected(0) && (mTipeList.isSelected(2)) && (mTipeList.isSelected(3))) {
                    Tipe.setText("President Suite \nDeluxe \nStandard");
                } else if (mTipeList.isSelected(1) && (mTipeList.isSelected(2)) && (mTipeList.isSelected(3))) {
                    Tipe.setText("Extra Deluxe \nDeluxe \nStandard");
                } else {
                    Tipe.setText("Belum Ditentukan");
                }
               
                if (mOpsiList.isSelected(0)) {
                    Opsi.setText("Room Service");
                } else if (mOpsiList.isSelected(1)) {
                    Opsi.setText("Meeting Room");
                } else if (mOpsiList.isSelected(2)) {
                    Opsi.setText("Transportation Service");
                } else if (mOpsiList.isSelected(3)) {
                    Opsi.setText("Laundry And Dry Cleaning");
                }else {
                    Tipe.setText("Belum Ditentukan");
                }

                dis.setCurrent(reviewForm);
            } catch (Exception error) {
                dis.setCurrent(new Alert("Review Reservasi Yang Anda Lakukan Gagal", error.getMessage(),
                        null, AlertType.ERROR));
            }
        }

    }
}

0 komentar:

Posting Komentar

 

Ummi Thaharani Lubis Copyright © 2010 Design by Ipietoon Blogger Template Graphic from Enakei