Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TEST3;
- import java.util.Scanner;
- public class TEST3 {
- public static final int TOTAL_FLOORS=3;
- public static final int ROOMS_PER_FLOOR=2;
- public static final int MAX_GUESTS=6;
- public static boolean roomACStatus[][] = new boolean[TOTAL_FLOORS][ROOMS_PER_FLOOR];
- public static double roomTemperature[][] = new double[TOTAL_FLOORS][ROOMS_PER_FLOOR];
- public static int roomOccupancy[][] = new int[TOTAL_FLOORS][ROOMS_PER_FLOOR];
- // DO NOT EDIT THIS METHOD
- public static void turnAcOn(int floor, int room, boolean status) {
- roomACStatus[floor-1][room-1] = status;
- roomTemperature[floor-1][room-1] = 0.0;
- }
- // DO NOT EDIT THIS METHOD
- public static boolean getRoomACStatus(int floor, int room) {
- return roomACStatus[floor-1][room-1];
- }
- // DO NOT EDIT THIS METHOD
- public static void setRoomTemperature(int floor, int room, double roomTemp) {
- roomTemperature[floor-1][room-1] = roomTemp;
- }
- // DO NOT EDIT THIS METHOD
- public static double getRoomTemperature(int floor, int room) {
- return roomTemperature[floor-1][room-1];
- }
- // DO NOT EDIT THIS METHOD
- public static void setRoomOccupancy(int floor, int room, int guests) {
- roomOccupancy[floor-1][room-1] = guests;
- }
- // DO NOT EDIT THIS METHOD
- public static int getRoomOccupancy(int floor, int room) {
- return roomOccupancy[floor-1][room-1];
- }
- public static void resetHotel(){
- turnAllACsOff();
- setAllRoomOccupancyToZero();
- System.out.println("START - Resetting Jeddah Palace Hotel system...");
- System.out.println("Setting all room a/c to off...Done!");
- System.out.println("Setting all rooms occupancy to zero...Done!");
- System.out.println("END - Done resetting Jeddah Palace Hotel System");
- }
- public static void turnAllACsOff(){
- int floor =1 , room =1;
- for(floor=1 ; floor<=3 ; floor++){
- for(room = 1 ; room <=2 ; room++){
- turnAcOn(floor, room , false);
- }
- }
- }
- public static void setAllRoomOccupancyToZero(){
- int floor =1;
- int room =1;
- for(floor=1 ; floor<=3 ; floor++){
- for(room = 1 ; room <=2 ; room++){
- turnAcOn(floor, room , false);
- }
- }
- setRoomOccupancy(floor , room , 0 );
- }
- public static void displayReport(){
- String x="";
- boolean ac = false ;
- System.out.println("");
- System.out.println("*** Jeddah Palace Hotel - Daily Report ***");
- System.out.println("AC status for all floors and rooms");
- for(int f = 1 ; f<=3 ; f++){
- System.out.print("floor "+f + " : " );
- for(int r = 1 ; r<=2 ; r++)
- ac = getRoomACStatus(f,r);
- if (ac){
- x="ON";
- System.out.print(x+" ");
- }
- else if(!ac) {
- x="OFF";
- System.out.print(x+" ");
- }
- }
- System.out.print("rooms are full");
- for(int f = 1 ; f<=3 ; f++){
- System.out.println("floor "+f + " : ");
- for (int r= 1 ; r < 3 ; r++){
- int room = getRoomOccupancy(f,r);
- if (room== 0){
- }else if(room > 0){
- }
- }
- }
- }
- public static boolean isRoomAvailable(int floor, int room){
- boolean Available= false;
- int RoomOcc = getRoomOccupancy(floor , room);
- if(RoomOcc > 0){
- Available = false;
- }
- else if(RoomOcc == 0){
- Available = true;
- }
- return Available;
- }
- public static int getFreeRoomNumber(){
- boolean d;
- int RoomNum=1;
- //الدور
- for(int f =1 ; f<4 ; f++){
- //الغرف
- for(int r=1 ; r<3 ; r++){
- if(r==1){
- d=isRoomAvailable(f, r);
- if(d==true){
- RoomNum= (100 * f ) + r;
- turnAcOn(f , r , true);
- return RoomNum;
- }
- }else if(r==2){
- d= isRoomAvailable(f,r);
- if(d==true)
- RoomNum= (100 * f ) + r;
- turnAcOn(f, r , true);
- return RoomNum;
- }
- }
- }
- return -1;
- }
- public static void checkInGuest(){
- Scanner input= new Scanner(System.in);
- int ss = getFreeRoomNumber();
- System.out.print("*** Guest Checkin Menu ***");
- if(ss== -1){
- System.out.print("Sorry room not available today!");
- }
- else if(ss!=0){
- System.out.print("Please enter your name :");
- String Name =input.nextLine();
- System.out.print("Please enter your mobile number :");
- String Num = input.next();
- System.out.print("Please enter number of guests :");
- int Guests= input.nextInt();
- System.out.print("*** Jeddah Palace Hotel ***");
- System.out.print("");
- System.out.print("Guest Details");
- System.out.print(" Name : "+Name);
- System.out.print(" Mobile numbe : "+Num);
- System.out.print(" Name : ");
- int getRoom= getFreeRoomNumber();
- System.out.print("Room Number: " + getRoom );
- int floor = getRoom / 100;
- int room = getRoom % 100;
- setRoomOccupancy(floor, room, 1);
- System.out.println("Your room is getting readied for you....Done!");
- System.out.println("-- Enjoy your stay with us! --");
- }
- }
- public static void checkOutGuest(){
- Scanner input=new Scanner (System.in);
- int roomNum,f ,r;
- System.out.print("*** Guest Checkout Menu ***");
- System.out.print("Please enter room number :");
- roomNum=input.nextInt();
- f=roomNum / 100;
- r=roomNum % 100;
- System.out.print("You have checked out of room :"+ roomNum);
- System.out.print("Thank you for staying with us!");
- turnAcOn(f,r,false);
- }
- public static void mainMenu(){
- Scanner input= new Scanner(System.in);
- int bbreak=1;
- while(bbreak == 1){
- System.out.println("*** Jeddah Palace Hotel ***");
- System.out.println("1. Guest Check in");
- System.out.println("2. Guest Check out");
- System.out.println("3. Print Report");
- System.out.println("Any other number to exit");
- System.out.print("Please enter your choice :");
- int choise = input.nextInt();
- switch (choise){
- case 1:
- checkInGuest();
- break;
- case 2:
- checkOutGuest();
- break;
- case 3:
- displayReport();
- break;
- default:
- System.out.println("Thank you for using the Jeddah Palace Hotel System!!!");
- }
- }
- }
- // DO NOT EDIT THE MAIN METHOD
- public static void main(String[] args) {
- // Initialize the Jeddah Hotel System
- resetHotel();
- // Display the daily report
- displayReport();
- // Display the main menu
- mainMenu();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement