Tugas Reservasi Hotel

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

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

/**
 * @author Marthin CH
 */
public class Reservation extends MIDlet implements CommandListener {

    private Command mContinueCommand, mDoneCommand, mCancelCommand, mExitCommand;
    private Form fListMenu, fRoom, fBookingAndPayment;
    private Display dDisplay;
    private TextField txtName, txtPhone;
    private DateField dfCheckIn, dfCheckOut;
    private ChoiceGroup cgGender, cgRoomList, cgFoodService, cgFacilities;
    private Alert aAlert;
    private StringItem sName, sGender, sPhone, sCheckIn, sCheckOut, sRoomList, sFacilities, sFoodService;

    public void startApp() {

        mContinueCommand = new Command("Continue", Command.OK, 0);
        mDoneCommand = new Command("Done", Command.OK, 0);
        mCancelCommand = new Command("Cancel", Command.OK, 0);
        mExitCommand = new Command("Exit", Command.OK, 1);

        if (fListMenu == null) {
            fListMenu = new Form("Register Menu");

            txtName = new TextField("Full Name : ", "", 100, TextField.INITIAL_CAPS_WORD);
            txtName.getString();
            fListMenu.append(txtName);

            cgGender = new ChoiceGroup("Gender : ", ChoiceGroup.EXCLUSIVE);
            cgGender.append("Male", null);
            cgGender.append("Female", null);
            fListMenu.append(cgGender);

            dfCheckIn = new DateField("Check In : ", DateField.DATE);
            fListMenu.append(dfCheckIn);

            dfCheckOut = new DateField("Check Out : ", DateField.DATE);
            fListMenu.append(dfCheckOut);

            txtPhone = new TextField("Phone Number : ", "", 100, TextField.PHONENUMBER);
            txtPhone.getString();
            fListMenu.append(txtPhone);

            fListMenu.addCommand(mExitCommand);
            fListMenu.addCommand(mContinueCommand);
            fListMenu.setCommandListener(this);

            dDisplay = Display.getDisplay(this);
        }

        if (fRoom == null) {
            fRoom = new Form("Hotel Room List's, Food Service, Facilities & Views");
            fRoom.addCommand(mCancelCommand);
            fRoom.addCommand(mDoneCommand);
            fRoom.setCommandListener(this);

            cgRoomList = new ChoiceGroup("Please select which room would like to use : ", List.EXCLUSIVE);
            cgRoomList.append("Standard", null);
            cgRoomList.append("Deluxe", null);
            cgRoomList.append("President Suite", null);
            fRoom.append(cgRoomList);

            cgFacilities = new ChoiceGroup("Please select which's one of addition facility in your room : ", List.EXCLUSIVE);
            cgFacilities.append("Internet + TV Analog", null);
            cgFacilities.append("Internet + Tv Cable", null);
            cgFacilities.append("Internet + Internet TV", null);
            fRoom.append(cgFacilities);

            cgFoodService = new ChoiceGroup("Please select which's your food service : ", List.EXCLUSIVE);
            cgFoodService.append("Breakfast & Lunch", null);
            cgFoodService.append("Lunch & Dinner", null);
            cgFoodService.append("Breakfast & Dinner", null);
            fRoom.append(cgFoodService);

            dDisplay = Display.getDisplay(this);
        }

        if (fBookingAndPayment == null) {
            fBookingAndPayment = new Form("Room's Booking and Payment");
            fBookingAndPayment.addCommand(mCancelCommand);
            fBookingAndPayment.addCommand(mExitCommand);
            fBookingAndPayment.setCommandListener(this);

            sName = new StringItem("Name                        : ", null);
            sGender = new StringItem("Gender                    : ", null);
            sPhone = new StringItem("Phone                      : ", null);
            sRoomList = new StringItem("RoomList                : ", null);
            sFacilities = new StringItem("Facilities            : ", null);
            sFoodService = new StringItem("Food Service         : ", null);
         
            //Set the string item into summary form
            fBookingAndPayment.append(sName);
            fBookingAndPayment.append(sGender);
            fBookingAndPayment.append(sPhone);
            fBookingAndPayment.append(sFacilities);
            fBookingAndPayment.append(sRoomList);
            fBookingAndPayment.append(sFoodService);
        }

        Display.getDisplay(this).setCurrent(fListMenu);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == mExitCommand) {
            destroyApp(true);
            notifyDestroyed();
        } else if (c == mContinueCommand) {
            if (cgFacilities.equals("Internet + Internet TV")) {
                aAlert = new Alert("This facility is only available fo president suite");
                dDisplay.setCurrent(aAlert, fListMenu);
            }
            dDisplay.setCurrent(fRoom);
        } else if (c == mDoneCommand) {
            String stName, stGender, stPhone, stRoomList, stFacilities, stFoodService = null;
           
            stName = txtName.getString();
            stGender = cgGender.getString(cgGender.getSelectedIndex());
            stPhone = txtPhone.getString();
            stRoomList = cgRoomList.getString(cgRoomList.getSelectedIndex());
            stFacilities = cgFacilities.getString(cgFacilities.getSelectedIndex());
            stFoodService = cgFoodService.getString(cgFoodService.getSelectedIndex());
           
            sName.setText(stName);
            sGender.setText(stGender);
            sPhone.setText(stPhone);
            sRoomList.setText(stRoomList);
            sFacilities.setText(stFacilities);
            sFoodService.setText(stFoodService);
           
            dDisplay.setCurrent(fBookingAndPayment);
        }
    }
}

Comments
0 Comments

0 Bacotan:

Related Posts Plugin for WordPress, Blogger...