Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Big Java textbook, chapters 5, 6 and 7. Develop a simple Hotel program. We will

ID: 3540321 • Letter: B

Question

Big Java textbook, chapters 5, 6 and 7.

Develop a simple Hotel program. We will have two classes, a Hotel class representing an individual hotel and a Room class. The Hotel class will contain several Room objects and will have several operations. We will also have a driver program to test the Hotel class.

Build a Hotel class that will store information about a Hotel. It will include a name and location. It should also include an Array of instances of class Room to hold information about each room. It will also have a int called occupiedCnt that keeps track of how many rooms in the hotel are occupied. You must use an Array, you cannot use an ArrayList. Set the Array to hold 10 Room objects.

Build a HotelTest class to test your application. Your test class should not require any interaction with the user. It should verify the correct operation of the constructor and all public methods in the Hotel class. Create at least 5 rooms.

Specific Requirements for the Hotel Class:

The Hotel will have an addRoom method that will create each room with the required information: room number, bed type, smoking/non-smoking, and the room rate. Create at least 5 rooms with different characteristics. Each room will also have a boolean field called occupied attribute that will be set to false when the room is created. Don't forget to increment the numOfRooms instance variable. Example values for the rooms are:

101 queen s 100
102 king n 110
103 king n 88
104 twin s 100
105 queen n 99

Hotel

theRooms: Array Room[]
name: String
location: String
occupiedCnt: int

numOfRooms: int

Hotel()

Hotel(String,String)
isFull() : boolean

isEmpty() : boolean
addRoom(int,String,char,double)
addReservation(String,char,String)

cancelReservation(String)
findReservation(String): int

printReservationList()

getDailySales() : double
occupancyPercentage() : double

toString():String

Access and mutator methods for name and location.

isEmpty() %u2013 returns a boolean that is true if all the rooms in the hotel are unoccupied.

When the cancelReservation() method executes, the hotel will search for the name of the visitor in each room. If it is found, the occupied attribute will be set to false. In either case a message will state whether or not the reservation was cancelled. This method calls the private utility method findReservation()to scan the list of rooms looking for a guest by name. It will return the index of the room in the Array of rooms or NOT_FOUND if the room is not found, which will be declared as:

private static final int NOT_FOUND = -1;

printReservationList() will scan through all the rooms and display all details for only those rooms that are occupied. For example:

Room Number: 102
Occupant name: Pinto
Smoking room: n
Bed Type: king
Rate: 110.0

Room Number: 103
Occupant name: Wilson
Smoking room: n
Bed Type: king
Rate: 88.0

occupancyPercentage() will divide occupiedCnt by the total number of rooms to provide an occupancy percentage.

Hotel Name : Beach Marriot
Number of Rooms : 5
Number of Occupied Rooms : 1


Room Details are:


Room

roomNum: int
bedType: String
rate: double
occupantName: String
smoking: char
occupied: boolean

Room()

Room(int,String,char,double)
getBedType(): String
getSmoking(): char       
getRoomNum(): int

getRoomRate(): double

getOccupant(): String
setOccupied(boolean)
setOccupant(String)

setRoomNum(int)

setBedType(String)

setRate(double)

setSmoking(char)

isOccupied(): boolean
toString(): String

isOccupied() method returns true if the room is occupied, false otherwise.

Several accessor and mutator methods for the Room class.

Submission Requirements:

Hotel

theRooms: Array Room[]
name: String
location: String
occupiedCnt: int

numOfRooms: int

Hotel()

Hotel(String,String)
isFull() : boolean

isEmpty() : boolean
addRoom(int,String,char,double)
addReservation(String,char,String)

cancelReservation(String)
findReservation(String): int

printReservationList()

getDailySales() : double
occupancyPercentage() : double

toString():String

Access and mutator methods for name and location.

Explanation / Answer

Sample output



Adding rooms to the hotel

There are total 5 rooms in the hotel

===================================================================

Checking if all the rooms in the hotel are empty

Yes, all the rooms in the hotel are empty

===================================================================

Looking for reservation in the hotel

Reservation 1



Yes, there is room available of your choice

Reservation is made



Reservation 2

No match found

Reservation is not made


Reservation 3



Yes, there is room available of your choice

Reservation is made


===================================================================

Printing details of all the rooms which are occupied



Room Number : 102

Occupant Name : Coffey

Smoking room : n

Bed Type : king

Rate : 110.0



Room Number : 104

Occupant Name : Brian

Smoking room : s

Bed Type : twin

Rate : 100.0



===================================================================


Checking if the hotel is full or not

The hotel is not full. We can accomodate few more people.


===================================================================

Find the total sale for today

Total sale for today is $:210.00

===================================================================


Lets check the occupancy percentage

Hotel occupancy percentage for today is :40.00%

===================================================================


Cancel the reservation for Brain

Reservation in the name of Brian is cancelled

===================================================================

Now that Brian's reservation is canceled, his details should not be printed

Printing details of all the rooms which are occupied



Room Number : 102

Occupant Name : Coffey

Smoking room : n

Bed Type : king

Rate : 110.0



===================================================================



All the methods are properly checked.

Printing the hotel details using toString method


Hotel Name :Beach Marriot Pensacola

Number of rooms :5

Number of Occupied Rooms :1


Room Number : 101

Occupant Name : null

Smoking room : s

Bed Type : queen

Rate : 100.0


Room Number : 102

Occupant Name : Coffey

Smoking room : n

Bed Type : king

Rate : 110.0


Room Number : 103

Occupant Name : null

Smoking room : n

Bed Type : king

Rate : 88.0


Room Number : 104

Occupant Name : Brian

Smoking room : s

Bed Type : twin

Rate : 100.0


Room Number : 105

Occupant Name : null

Smoking room : n

Bed Type : queen

Rate : 99.0