Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.67 KB | None | 0 0
  1. /**
  2.  * Use this method to change the status of the check in/check out
  3.  *
  4.  */
  5.     private void changeGuestCheck(String sBookingInput) {
  6.         Booking selectedBooking = Bookings.get(Integer.parseInt(sBookingInput));
  7.         //Guest selectedGuest = Guests.get(Integer.parseInt(sBookingInput));
  8.         Guest selectedGuest = Guests.stream()
  9.                 .filter(Guest -> Guest.getsMail().equals(selectedBooking.getsMail()))
  10.                 .findAny()
  11.                 .orElse(null);
  12.         selectedGuest.setbCheckedIn(false);
  13.         Guests.set(Integer.parseInt(sBookingInput), selectedGuest);
  14.  
  15.     }
  16. /**
  17.  * Use this method to change the status of a specifik spot depending on the booking
  18.  */
  19.     private void changeSpotCheck(String sBookingInput) {
  20.         Booking selectedBooking = Bookings.get(Integer.parseInt(sBookingInput));
  21.         //Guest selectedGuest = Guests.get(Integer.parseInt(sBookingInput));
  22.         Spot selectedSpot = Spots.get(selectedBooking.getiSpotNR());
  23.         selectedSpot.setbVacant(true);
  24.         Spots.set(Integer.parseInt(sBookingInput), selectedSpot);
  25.     }
  26.     /*
  27.     Skapar en instans av bokningen och skriver ut den
  28.     Use this method to display a specifik booking and print it out
  29.     */
  30.     private void displayBooking(String sBookingInput) {
  31.        
  32.         Booking selectedBooking = Bookings.get(Integer.parseInt(sBookingInput));
  33.         System.out.println(selectedBooking);
  34.     }
  35.  
  36.    
  37.     /**
  38.     * Use this method to fetch the income from an accomendation
  39.     * returns integer result with cottage-, trailer- or tentprice
  40.     */
  41.     public int[] calMoneyEarned() {
  42.         int iCottagePrice = 0;
  43.         int iTrailerPrice = 0;
  44.         int iTentPrice = 0;
  45.         for (int counter = 0; counter < Bookings.size(); counter++) {
  46.             Booking selectedBooking = Bookings.get(counter);
  47.             String sAccType = selectedBooking.getsAccommodation();
  48.             switch (sAccType) {
  49.                  case "Cottage":
  50.                         iCottagePrice += selectedBooking.getiTotalbill();
  51.                         break;
  52.                     case "RV":
  53.                         iTrailerPrice += selectedBooking.getiTotalbill();
  54.                         break;
  55.                     case "Tent":
  56.                         iTentPrice += selectedBooking.getiTotalbill();
  57.                         break;
  58.             }
  59.         }
  60.  
  61.         int iTotalRevenue = iCottagePrice + iTrailerPrice + iTentPrice;      
  62.         int[] result = new int[4];
  63.         result[0] = iTotalRevenue;
  64.         result[1] = iCottagePrice;
  65.         result[2] = iTrailerPrice;
  66.         result[3] = iTentPrice;
  67.         return result;
  68.     }
  69.    
  70.     /**
  71.     * Use this method to
  72.     */
  73. public int[] calEarned() {
  74.         int iCottageGuest = 0;
  75.         int iTrailerGuest = 0;
  76.         int iTentGuest = 0;
  77.         for (int counter = 0; counter < Bookings.size(); counter++) {
  78.             Booking selectedBooking = Bookings.get(counter);
  79.             String sAccType = selectedBooking.getsAccommodation();
  80.             switch (sAccType) {
  81.                  case "Cottage":
  82.                         iCottageGuest ++;
  83.                         break;
  84.                     case "RV":
  85.                         iTrailerGuest ++;
  86.                         break;
  87.                     case "Tent":
  88.                         iTentGuest ++;
  89.                         break;
  90.             }
  91.         }
  92.  
  93.         int iTotalRevenue = iCottageGuest + iTrailerGuest + iTentGuest;      
  94.         int[] result = new int[4];
  95.         result[0] = iTotalRevenue;
  96.         result[1] = iCottageGuest;
  97.         result[2] = iTrailerGuest;
  98.         result[3] = iTentGuest;
  99.         return result;
  100.     }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement