Advertisement
Guest User

Untitled

a guest
Mar 28th, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.36 KB | None | 0 0
  1.  
  2. package TEST3;
  3.  
  4. import java.util.Scanner;
  5.  
  6.  
  7. public class TEST3 {
  8.  
  9.      public static final int TOTAL_FLOORS=3;
  10.     public static final int ROOMS_PER_FLOOR=2;
  11.     public static final int MAX_GUESTS=6;
  12.     public static boolean roomACStatus[][] = new boolean[TOTAL_FLOORS][ROOMS_PER_FLOOR];
  13.     public static double roomTemperature[][] = new double[TOTAL_FLOORS][ROOMS_PER_FLOOR];
  14.     public static int roomOccupancy[][] = new int[TOTAL_FLOORS][ROOMS_PER_FLOOR];
  15.    
  16.    
  17.     // DO NOT EDIT THIS METHOD
  18.     public static void turnAcOn(int floor, int room, boolean status) {
  19.         roomACStatus[floor-1][room-1] = status;
  20.         roomTemperature[floor-1][room-1] = 0.0;
  21.     }
  22.    
  23.     // DO NOT EDIT THIS METHOD
  24.     public static boolean getRoomACStatus(int floor, int room) {
  25.         return roomACStatus[floor-1][room-1];
  26.     }
  27.    
  28.     // DO NOT EDIT THIS METHOD
  29.     public static void setRoomTemperature(int floor, int room, double roomTemp) {
  30.         roomTemperature[floor-1][room-1] = roomTemp;
  31.     }
  32.  
  33.     // DO NOT EDIT THIS METHOD
  34.     public static double getRoomTemperature(int floor, int room) {
  35.         return roomTemperature[floor-1][room-1];
  36.     }
  37.  
  38.     // DO NOT EDIT THIS METHOD
  39.     public static void setRoomOccupancy(int floor, int room, int guests) {
  40.         roomOccupancy[floor-1][room-1] = guests;
  41.     }
  42.  
  43.     // DO NOT EDIT THIS METHOD
  44.     public static int getRoomOccupancy(int floor, int room) {
  45.         return roomOccupancy[floor-1][room-1];
  46.     }
  47.    
  48.    
  49.    
  50.    
  51.     public static void resetHotel(){
  52.  
  53.         turnAllACsOff();
  54.         setAllRoomOccupancyToZero();
  55.         System.out.println("START - Resetting Jeddah Palace Hotel system...");
  56.         System.out.println("Setting all room a/c to off...Done!");
  57.         System.out.println("Setting all rooms occupancy to zero...Done!");
  58.         System.out.println("END - Done resetting Jeddah Palace Hotel System");
  59.      
  60.     }
  61.     public static void turnAllACsOff(){
  62.        int floor =1 , room =1;
  63.    
  64.        for(floor=1 ; floor<=3 ; floor++){
  65.         for(room = 1 ; room <=2 ; room++){
  66.          turnAcOn(floor, room , false);  
  67.         }
  68.     }
  69.     }
  70.    
  71.     public static void setAllRoomOccupancyToZero(){
  72.        int floor =1;
  73.        int room =1;
  74.    
  75.        for(floor=1 ; floor<=3 ; floor++){
  76.         for(room = 1 ; room <=2 ; room++){
  77.          turnAcOn(floor, room , false);  
  78.         }
  79.     }
  80.         setRoomOccupancy(floor , room , 0 );
  81.     }
  82.    
  83.     public static void displayReport(){
  84.       String x="";
  85.       boolean ac = false ;
  86.         System.out.println("");
  87.        System.out.println("*** Jeddah Palace Hotel - Daily Report ***");
  88.        System.out.println("AC status for all floors and rooms");
  89.      
  90.        for(int f = 1 ; f<=3 ; f++){
  91.         System.out.print("floor  "+f + " : " );
  92.         for(int r = 1 ; r<=2 ; r++)
  93.          ac = getRoomACStatus(f,r);
  94.        
  95.         if (ac){
  96.             x="ON";
  97.              System.out.print(x+"     ");
  98.        }
  99.         else if(!ac) {
  100.             x="OFF";
  101.            System.out.print(x+"     ");
  102.            
  103.         }
  104.         }
  105.        System.out.print("rooms are full");
  106.        
  107.        
  108.      for(int f = 1 ; f<=3 ; f++){
  109.          System.out.println("floor  "+f + " : ");
  110.          for (int r= 1 ; r < 3 ; r++){
  111.              int room = getRoomOccupancy(f,r);
  112.              if (room== 0){
  113.              
  114.              }else if(room > 0){
  115.                  
  116.              
  117.              }
  118.          
  119.      }
  120.    
  121.     }
  122.     }
  123.    
  124.     public static boolean isRoomAvailable(int floor, int room){
  125.       boolean Available= false;
  126.       int RoomOcc = getRoomOccupancy(floor , room);
  127.       if(RoomOcc > 0){
  128.       Available = false;
  129.       }
  130.       else if(RoomOcc == 0){
  131.           Available = true;
  132.       }
  133.         return Available;
  134.       }
  135.      
  136.    
  137.     public static int getFreeRoomNumber(){
  138.    boolean d;
  139.    int RoomNum=1;
  140.    //الدور
  141.         for(int f =1 ; f<4 ; f++){
  142.         //الغرف
  143.             for(int r=1 ; r<3 ; r++){
  144.             if(r==1){
  145.                d=isRoomAvailable(f, r);
  146.                if(d==true){
  147.                   RoomNum= (100 * f ) + r;
  148.               turnAcOn(f , r , true);
  149.               return RoomNum;
  150.                }
  151.                
  152.            
  153.            
  154.             }else if(r==2){
  155.               d= isRoomAvailable(f,r);  
  156.              
  157.               if(d==true)
  158.                   RoomNum= (100 * f ) + r;
  159.               turnAcOn(f, r , true);
  160.               return RoomNum;
  161.             }
  162.        
  163.         }
  164.             }
  165.        
  166.         return -1;
  167.         }
  168.        
  169.  
  170.     public static void checkInGuest(){
  171.       Scanner input= new Scanner(System.in);
  172.     int ss = getFreeRoomNumber();
  173.       System.out.print("*** Guest Checkin Menu ***");
  174.             if(ss== -1){
  175.       System.out.print("Sorry room not available today!");
  176.       }
  177.       else if(ss!=0){
  178.        System.out.print("Please enter your name :");
  179.        String Name =input.nextLine();
  180.        System.out.print("Please enter your mobile number :");
  181.        String Num = input.next();
  182.        System.out.print("Please enter number of guests :");
  183.        int Guests= input.nextInt();
  184.        System.out.print("*** Jeddah Palace Hotel ***");
  185.        System.out.print("");
  186.        System.out.print("Guest Details");
  187.        System.out.print("   Name :          "+Name);
  188.        System.out.print("   Mobile numbe :          "+Num);
  189.        System.out.print("   Name :          ");
  190.        int getRoom= getFreeRoomNumber();
  191.        System.out.print("Room Number:       " + getRoom  );
  192.        int floor = getRoom / 100;
  193.        int room = getRoom % 100;
  194.        setRoomOccupancy(floor, room, 1);
  195.        System.out.println("Your room is getting readied for you....Done!");
  196.        System.out.println("-- Enjoy your stay with us! --");
  197.      
  198.        
  199.     }
  200.     }
  201.     public static void checkOutGuest(){
  202. Scanner input=new Scanner (System.in);
  203. int roomNum,f ,r;
  204. System.out.print("*** Guest Checkout Menu ***");
  205. System.out.print("Please enter room number :");
  206.  roomNum=input.nextInt();
  207.  f=roomNum / 100;
  208.  r=roomNum % 100;
  209. System.out.print("You have checked out of room :"+ roomNum);
  210. System.out.print("Thank you for staying with us!");
  211. turnAcOn(f,r,false);
  212.     }
  213.     public static void mainMenu(){
  214.       Scanner input= new Scanner(System.in);
  215.       int bbreak=1;
  216.       while(bbreak == 1){
  217.      System.out.println("*** Jeddah Palace Hotel ***");
  218.       System.out.println("1. Guest Check in");
  219.       System.out.println("2. Guest Check out");
  220.       System.out.println("3. Print Report");
  221.        System.out.println("Any other number to exit");
  222.         System.out.print("Please enter your choice :");
  223.       int choise = input.nextInt();
  224.       switch (choise){
  225.           case 1:
  226.                  checkInGuest();
  227.                   break;
  228.           case 2:
  229.               checkOutGuest();
  230.               break;
  231.           case 3:
  232.               displayReport();
  233.               break;
  234.           default:
  235.               System.out.println("Thank you for using the Jeddah Palace Hotel System!!!");
  236.    
  237.     }
  238.     }
  239.     }
  240.  
  241.  
  242.     // DO NOT EDIT THE MAIN METHOD
  243.     public static void main(String[] args) {
  244.        
  245.         // Initialize the Jeddah Hotel System
  246.        resetHotel();
  247.        
  248.         // Display the daily report
  249.         displayReport();
  250.        
  251.         // Display the main menu
  252.         mainMenu();
  253.    
  254.    
  255. }
  256. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement