Question
Hotel class The Hotel class (see Hotel.java) represents a hotel and extends the Building class. The instance variables are provided below. A hotel is a
Hotel class
The Hotel class (see Hotel.java) represents a hotel and extends the Building class. The instance variables are provided below. A hotel is a building with floors and rooms per floor. In addition, a hotel has a special room called the penthouse, that only people with pentHouseMembers in their name can occupy. For example, if pentHouseMembers is Smith, anyone with Smith in their name (e.g., John Smith, Smith Mary, etc.) can occupy the penthouse. A hotel may or may not have a pool. We provided a toString() method for this class; do not modify it. private String hotelName, pentHouseMembers; private Room pentHouseRoom; private boolean hasPool; a. public Hotel(String hotelName, String address, int maxFloors, int roomsPerFloor, int roomCapacity, String pentHouseMembers, int pentHouseCapacity, boolean hasPool) - Initializes the instance variables with the corresponding parameter values. The constructor will call the super class constructor to initialize the building component of the hotel. Make sure you use roomCapacity to initialize the capacity of hotel rooms and pentHouseCapacity to initialize the penthouse capacity. b. public boolean addOccupant(String name, int floorIndex, int roomNumberIndex) - If name contains the pentHouseMembers string, the name will be added to the penthouse; otherwise it will be added to the room associated with the specified indices. The method will return true if the name was added as an occupant and false otherwise. You can use the String class contains method to verify whether name has the pentHouseMembers string. This method overrides a method. c. public ArrayList getOccupants(boolean pentHouse, int floorIndex, int roomIndex, boolean sorted) - Returns an ArrayList with the occupants of a room. If penthouse is true, ONLY the occupants of the penthouse will be returned. If penthouse if false, ONLY the occupants of the room associated with the specified indices will be returned. If the sorted parameter is true, the ArrayList will be sorted (using Collections.sort()) before it is returned. If the indices are invalid an empty ArrayList will be returned. d. public boolean hotelHasPool() - Get method for hasPool. e. public int[] getFloorMaxOccupants() - Returns an array with two integers (array of size 2). The first entry of the array is the index of the floor with the maximum number of occupants, and the second value is the maximum number of occupants on that floor. If two floors have the same maximum number of occupants, the first floor found (the one with the lowest index value) will be used. If the floors are empty, the returned array will have the values 0 and 0. This method does not look at the occupants in the penthouse room; it looks for the maximum number of occupants only on floors. f. public static int totalNumberHotelsWithPool(ArrayList buildings) - This static method has as parameter an ArrayList of Building references. Remember that not all buildings are hotels. The method will return the number of buildings that are hotels and that have a pool.
/* Provided: do not modify */ @Override public String toString() { String answer = "Hotel: " + hotelName + " ";
answer += "PentHouseMembers: " + pentHouseMembers + " "; answer += "PentHouseRoom: " + pentHouseRoom + " "; answer += "Pool: " + (hasPool ? "Yes" : "No") + " "; answer += super.toString();
return answer; }
Hotel class please, an upvote for exactly follow the instructions, thanks.
The Room class (see Room.java) represents a room in a building. The instance variables (see below) associated with this class are capacity (maximum number of occupants in a room) and occupants (names of persons that are in the room). You can assume names are unique. We provided a toString() method for this class; do not modify it. private int capacity; private ArrayListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started