Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HotelManagement Class This is the driver class for your program. It will contain a method for setting up an initial hotel and the main method

image text in transcribed

HotelManagement Class This is the driver class for your program. It will contain a method for setting up an initial hotel and the main method which will start the rest of your program. HotelMenu Class This class controls user input and is the main point of interaction with your program. All input and output should be handled through this class. Hotel Class Contains the rooms that guests can reserve. Manages the actual creation and cancelation of reservations. Room Class Represents the places within the hotel in which a guest can reserve and maintains information about the current occupants. Guest Class Represents the individual who makes a reservation and the person who the reservation is under. BedType Enum Each room has exactly one bed which is either a double, queen, or king sized bed. This enum provides convenient means for dealing with the different types. We will go through the requirements for each class in the following sections. HotelManagement Class This class serves two different purposes. First it is the initial entry point for your program. It is often best to separate the entry point of a program from other parts of the code. This makes it easier to identify the starting point and also allows other classes to focus on their own responsibilities. You need two methods for this class: static Hotel createInitialHotel() this method is in charge of just creating an initial hotel for the program to use. You will need to create a new Hotel object and add an initial set of rooms to that hotel. It is fine to use a small number of hotel rooms, four to five should be enough. The main method the only responsibilities of the main method are to get the initial hotel from the previous method, create a new HotelMenu for that hotel, and then to call the startMenu method. HotelMenu Class The HotelMenu class contains all code related to input and output. It is common to separate classes that deal with input and output from other classes that deal primarily with logic or maintaining data. This makes it easier to identify such code and to make changes to that code when necessary. You must have the following instance variables: A Scanner object that will be used for reading input from the user. A Hotel object to maintain rooms and reservations. You must have the following public methods: void startMenu() This is the method that presents the initial menu when the program first starts up (see User Menus). It is called by the main method when running the program. This method will take in a users selection for the menu and then call the private handleSelection method to deal with the users selection. It will do this in an infinite loop until the program is finally exited. You must have the following private helper methods: HotelMenu(Hotel hotel) a parameterized constructor for setting up a new menu for a given Hotel. boolean handleSelection(int selection) take in the users selection from the start menu and calls the appropriate code to handle the selection. void makeReservation() called by handleSelection when the user chooses to make a new reservation. Prompts the user for their name, the size of their party, and the type of bed they would like, then attempts to make a reservation with the hotel. If a reservation is successful (the bed type requested is available), then it ends. Otherwise, it requests that the user enter a different bed type. void cancelReservation() called by handleSelection when the user chooses to cancel a reservation. Asks for a name for a reservation and asks the hotel to cancel that reservation. If the name was valid, the reservation is cancelled, and the room freed. Otherwise, asks for a different name. void listReservations() called by handleSelection when the user chooses to see all reservations. Retrieves an array of reserved rooms from the hotel and displays them along with the guest information. void listRooms() called by handleSelection when the user choose to see all rooms. Retrieves an array of all rooms from the hotel and displays them along with the guest information. Hotel Class While the HotelMenu class handles input and output, it is not the proper place to store information on the rooms and their availability. Instead, the Hotel class does this and can be called by the HotelMenu class when needed. You must have the following instance variables: An array that contains all Rooms in the hotel. It should be larger than the current number of Rooms in order to make space for expansion. An integer for storing the current number of rooms. The current number of rooms is a different value from the maximum number of rooms (the size of the above array). An integer for storing the current number of reservations. A String that holds the name of the hotel. You must have the following public methods: Hotel() - A default constructor that calls the parameterized constructor by using the this keyword. Sends in Undecided for the Hotel name and 10 for the maxNumberOfRooms Hotel(String name, int maxNumberOfRooms) - A parameterized constructor that takes in a name for the Hotel and a maximum number of rooms to initialize the array of Rooms. In addition to the name and Rooms array, it should also initialize the number of current rooms and the number of current reservations to 0. A getName and setName for accessing and modifying the name of the Hotel. void addRoom(Room newRoom) Should allow for adding a new room to a Hotel and should also increase the number of rooms in the Hotel by one. boolean makeReservation(Guest newGuest, BedType desiredBedType) Finds an available room with the requested bed type and reserves the room for the guest. Returns true and increases the number of current reservations if it succeeds, and returns false if an appropriate room does not exist. boolean cancelReservation(String guestName) Finds a room that is occupied by a guest with the matching name. Returns true and decreases the number of current reservations if it succeeds, and returns false if it cannot find a matching name. Room[] getRooms() Returns an array that only contains current Rooms in the Hotel. Since your Rooms array should have room for expansion (i.e., the Rooms array is not completely filled), you will need to copy Rooms from the Rooms array into a new array that is the length of the current number of Rooms. Room[] getReservations() Returns an array of Rooms with reservations. Room Class Rooms are the locations of stay for Guests in a Hotel. As such, they should keep track of any information that defines them as well as who is currently occupying them. You must have the following instance variables: An integer indicating the room number. A Guest object that indicates the current occupants A BedType value for indication the type of bed that will be in the Room. For simplicity, each Room only contains a single bed. You must have the following public methods: Room(int roomNumber, BedType bedType) A parameterized constructor that initializes the instance variables for the class. It sets the Guest originally to null to indicate that it is available. boolean reserveRoom(Guest newGuest) Attempts to set the Guest for the Room. Returns true if the Room was previously available and the reservation was made. Returns false otherwise. void freeRoom() Sets the Guest back to null. boolean isAvailable() Returns whether the Room is open for reservation. String toString() Returns a String that represents the Room. Includes the room number, the bed type, and if a Guest exists will attach the result of Guests toString. If a Guest is not currently present, attaches No Guests to the end of the String instead. A getGuestName and getPartySize for returning information about the Guest. A getRoomNumber for returning the Rooms number. A getBedType and setBedType for accessing and modifying the type of bed in the room. Guest Class The Guest class maintains information regarding the paying guests of the hotel and their party size. You must have the following instance variables: A String value for the name of the Guest An integer value for the size of the Guests party You must have the following public methods: Guest(String name, int partySize) initializes the instance variables for the class. A getName and setName for accessing and modifying the Guests name. A getPartySize and setPartySize for accessing and modifying the size of the Guests party. String toString() Returns a String that represents the Guest. Includes the Guests name and their partys size. The BedType Enum The purpose of the enum is for convenience in dealing with sets of related alternatives. For instance, dealing with days in a week or months in a year. In this case, we want to make use of an enum for the three different types of Beds (DOUBLE, QUEEN, and KING). We went over the basic syntax of enums in the first week of the course. You should create and store a BedType enum A particularly useful operation when dealing with an enum is the ability to use integer indices to get back out a particular enum value. For instance, if the enum was declared with DOUBLE first, DOUBLE would be the same as BedType.values()[0]. BedType.values() returns an array and the [0] says to get the first value in that array. This is useful for when you need to take in an integer value through a Scanner object and want to turn it into a valid BedType. User Menus When you first run your program, the starting menu should look as follows: Welcome to Holiday Inn Express! Please make a selection from the following options: 1. Make Reservation 2. Cancel Reservation 3. List Reservations 4. List All Rooms 5. Exit Program Selection: The user can then type an integer followed by enter to make a selection. Make Reservation should prompt the user for a guests name, the size of a party, and a bed type. Cancel Reservation should prompt the user for a guests name that should currently be in the system. List Reservations will list all room details for currently reserved rooms and List All Rooms will list out the details of every room in the Hotel. Each of these menus follow. Note that an appropriate message should be printed any time a user enters a bad selection and the user should be prompted to enter a new value. Make Reservation: Please enter the guest's name: John Smith Please enter the size of the guest's party: 3 Please select the desired bed type: 1. Double 2. Queen 3. King Selection: 2 Cancel Reservation: Please enter the name on the reservation: John Smith List Reservations: Room Number: 3 Bed Type: QUEEN Guest Name: John Doe Guest Party Size: 2 Room Number: 5 Bed Type: KING Guest Name: John Smith Guest Party Size: 3 List All Rooms: Room Number: 1 Bed Type: DOUBLE No Guests Room Number: 2 Bed Type: DOUBLE No Guests Room Number: 3 Bed Type: QUEEN Guest Name: John Doe Guest Party Size: 2 Room Number: 4 Bed Type: QUEEN No Guests Room Number: 5 Bed Type: KING Guest Name: John Smith Guest Party Size: 3

Assignment There are a total of five classes and one enum required for this project. Over the course of the project, it is important that you pay attention to how different responsibilities are separated between the classes and how they work in conjunction to handle a problem. quick lis of the necear orths pogram ane HotelManagement Class This is the driver class for your program. It will contain a method for setting up an initial hotel and the main method which will start the rest of your program. HotelMenu Class- This class controls user input and is the main point of interaction with your program. All input and output should be handled through this class. Hotel Class-Contains the rooms that guests can reserve. Manages the actual creation and cancelation of reservations. Room Class Represents the places within the hotel in which a guest can reserve and maintains information about the current occupants. Guest Class - Represents the individual who makes a reservation and the person who the reservation is under BedType Enum Each room has exactdly one bed which is either a double, queen, or king sized bed. This enum provides convenient means for dealing with the different types

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago