Advertisement
Guest User

6a

a guest
Oct 17th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. public class ResortRoom{
  2. public static final int STREET_SIDE = 1;
  3. public static final int OCEAN_SIDE = 0;
  4. private int occupants;
  5. private int roomType;
  6. /**
  7. * @param numberOfOccupants int
  8. * @param roomType int
  9. * constructor of the program
  10. */
  11. public ResortRoom(int roomType, int numberOfOccupants)
  12. {
  13. occupants = numberOfOccupants;
  14. if( roomType!= OCEAN_SIDE && roomType!=STREET_SIDE )
  15. {
  16. roomType = OCEAN_SIDE;
  17. }
  18. else
  19. {
  20. this.roomType = roomType;
  21. }
  22. }
  23. /**
  24. * @return cost of room
  25. */
  26. public double getCost()
  27. {
  28. if(occupants == 1 || occupants == 2)
  29. {
  30. if(roomType == OCEAN_SIDE)
  31. {
  32. return (250.0);
  33. }
  34. else
  35. {
  36. return (175.0);
  37. }
  38. }
  39. else if(occupants == 3 || occupants == 4)
  40. {
  41. if(roomType == OCEAN_SIDE)
  42. {
  43. return (370.0);
  44. }
  45. else
  46. {
  47. return (260.0);
  48. }
  49. }
  50. else{
  51. int people = occupants - 4;
  52. int additionalCost = (100 * people);
  53. if (roomType == OCEAN_SIDE)
  54. {
  55. return (370.0 + additionalCost);
  56. }
  57. else
  58. {
  59. return (260.0 + additionalCost);
  60. }
  61. }
  62. }
  63.  
  64. /**
  65. * @return the number of occupants in the room
  66. */
  67. public int getOccupants()
  68. {
  69. return occupants;
  70. }
  71. /**
  72. * @param occupantNumber int
  73. */
  74. public void setOccupants(int occupantNo){
  75. occupants = occupantNo;
  76. if(occupants <= 0)
  77. {
  78. occupants =2;
  79. }
  80.  
  81. }
  82. /**
  83. * getType() String
  84. * @return "street"
  85. */
  86. public String getType()
  87. {
  88. if(this.roomType == 1)
  89. {
  90. return "street";
  91. }
  92. else
  93. {
  94. return "ocean";
  95. }
  96. }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement