Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.58 KB | None | 0 0
  1. public class Hotel
  2. {
  3.  
  4. private Room[] theRooms;
  5. private String name;
  6. private int totalDays;
  7. private double totalRate;
  8. private int singleCount;
  9. private int doubleCount;
  10. private int roomsRented;
  11. private int NUM_ROOMS;
  12. private int NOT_FOUND;
  13.  
  14. /**
  15. Constructer
  16. */
  17. public Hotel(String hotelnam)
  18. {
  19. name = hotelnam;
  20. NUM_ROOMS = 20;
  21. theRooms = new Room[NUM_ROOMS];
  22. }
  23. /**
  24. will return the total rental income by summing the rental cost for each room rented out.
  25. */
  26. public double getTotalRentalSales()
  27. {
  28. int i = 0;
  29. double adder = 0.0;
  30. while(i < NUM_ROOMS)
  31. {
  32.  
  33. adder = (theRooms[i].getRate() * theRooms[i].getNumOfDays()) + adder;
  34.  
  35. i++;
  36. }
  37. return totalDays;
  38. }
  39. /**
  40. will return the average number of days that rooms are rented out for.
  41. */
  42. public double getAvgDays()
  43. {
  44. int i2 = 0;
  45. double adder2 = 0.0;
  46.  
  47. while(i2 < NUM_ROOMS)
  48. {
  49.  
  50. adder2 = theRooms[i2].getNumOfDays() + adder2;
  51.  
  52.  
  53. i2++;
  54. }
  55.  
  56. adder2 = adder2/i2;
  57. return adder2;
  58.  
  59. }
  60. /**
  61. will return the average rental rate for the rooms.
  62. */
  63. public double getAvgRate()
  64. {
  65. int i3 = 0;
  66. double adder3 = 0.0;
  67. double num = 0.0;
  68.  
  69. while(i3 < NUM_ROOMS)
  70. {
  71.  
  72.  
  73. totalRate = theRooms[i3].getRate() + totalRate;
  74. num++;
  75.  
  76. i3++;
  77. }
  78. adder3 = totalRate/num;
  79. return totalRate;
  80.  
  81. }
  82. /**
  83. will return the number of rooms with one bed.
  84. */
  85. public int getSingleCount()
  86. {
  87. int i4 = 0;
  88. int adder4 = 0;
  89. while(i4 < NUM_ROOMS)
  90. {
  91. if (theRooms[i4].getNumBeds() == 1)
  92. {
  93. singleCount++;
  94. }
  95. i4++;
  96. }
  97. return singleCount;
  98. }
  99. /**
  100. will return the number of rooms with two beds.
  101. */
  102. public int getDoubleCount()
  103. {
  104. int i5 = 0;
  105. int adder5 = 0;
  106. while(i5 < NUM_ROOMS)
  107. {
  108. if (theRooms[i5].getNumBeds() == 2)
  109. {
  110. doubleCount++;
  111. }
  112. i5++;
  113. }
  114. return doubleCount;
  115.  
  116. }
  117. /**
  118. will print out the information for each room by calling the toString method for each Room instance.
  119. */
  120. public void printRentalList()
  121. {
  122. int i6 = 0;
  123. while(i6 < NUM_ROOMS)
  124. {
  125. theRooms[i6].toString();
  126. i6++;
  127. }
  128. }
  129. /**
  130.  
  131. FINSH LATER
  132. public void addReservation(String gname, int theroom, int beds, double therate, int thedays)
  133. {
  134.  
  135.  
  136.  
  137. gname = theRooms[].setGuest();
  138. theroom = theRooms[].setNumber();
  139. beds = theRooms[].setNumBeds();
  140. therate = theRooms[].setRate();
  141. thedays = theRooms[].setNumOfDays();
  142.  
  143. }
  144. */
  145. /**
  146. takes a room number and checks whether there is a reservation for this room. If a reservation is found, the method will print out the room's information using the room’s toString method. If not, the method prints out a message indicating that the reservation was not found.
  147.  
  148. public reportReservation(int checkroom)
  149. {
  150. if (checkroom)
  151. {
  152.  
  153. }
  154. }
  155. */
  156.  
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement