Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ResortRoom{
- public static final int STREET_SIDE = 1;
- public static final int OCEAN_SIDE = 0;
- private int occupants;
- private int roomType;
- /**
- * @param numberOfOccupants int
- * @param roomType int
- * constructor of the program
- */
- public ResortRoom(int roomType, int numberOfOccupants)
- {
- occupants = numberOfOccupants;
- if( roomType!= OCEAN_SIDE && roomType!=STREET_SIDE )
- {
- roomType = OCEAN_SIDE;
- }
- else
- {
- this.roomType = roomType;
- }
- }
- /**
- * @return cost of room
- */
- public double getCost()
- {
- if(occupants == 1 || occupants == 2)
- {
- if(roomType == OCEAN_SIDE)
- {
- return (250.0);
- }
- else
- {
- return (175.0);
- }
- }
- else if(occupants == 3 || occupants == 4)
- {
- if(roomType == OCEAN_SIDE)
- {
- return (370.0);
- }
- else
- {
- return (260.0);
- }
- }
- else{
- int people = occupants - 4;
- int additionalCost = (100 * people);
- if (roomType == OCEAN_SIDE)
- {
- return (370.0 + additionalCost);
- }
- else
- {
- return (260.0 + additionalCost);
- }
- }
- }
- /**
- * @return the number of occupants in the room
- */
- public int getOccupants()
- {
- return occupants;
- }
- /**
- * @param occupantNumber int
- */
- public void setOccupants(int occupantNo){
- occupants = occupantNo;
- if(occupants <= 0)
- {
- occupants =2;
- }
- }
- /**
- * getType() String
- * @return "street"
- */
- public String getType()
- {
- if(this.roomType == 1)
- {
- return "street";
- }
- else
- {
- return "ocean";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement