Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This assignment is due tomorrow. Please help me do it. Thank you. Question 1: Booking System 100 points) For this question, you will write several

This assignment is due tomorrow. Please help me do it. Thank you.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Question 1: Booking System 100 points) For this question, you will write several classes, and then create and use instances of those classes in order to simulate a hotel booking system. Note that in addition to the required methods below, you are free to add as many other private methods as you want (no additional public method is allowed). (a) (20 points) Write a class Room. A Room has the following private attributes: . A String type The Room class also contains the following public methods: . A constructor that takes as input the type of the room and uses it to initialize the attributes. Note that there are only 3 type of Rooms supported by the program: double, queen, and king. If the input is not one of these types, then the constructor should throw an IllegalArgumentEx- ception explaining that no room of such type can be created. The price of the room is based on its type as follows: $90 for a double, $110 for a queen, $150 for a king. The constructor should set the availability for a new room to be true. . getPrice which returns the price of the room. . getAvailability which returns the availability of the room. changeAvailability which takes no input and sets the value stored in the availability attribute to be the opposite of the one currently there. . A findAvailableRoom method which takes as input an array of Rooms as well as a String indicating the room type. The method should return the first available room in the array of the indicated type. If no such room exists (either because all rooms of said type are occupied, or because no room of such type is in the array), the method returns null. (b) (10 points) Write a class Reservation. A Reservation has the following private attributes: .A String name A Room roomReserved The Reservation class also contains the following public methods: . A constructor that takes as input a Room and the name under which the reservation is made. getName which returns the name under which the reservation was made. getRoom which returns the Room that has been reserved. (c) (40 points) Write a class Hotel. This class has three private attributes: . A String name . An array of Roos . An array of Reservation It also has the following methods: Question 1: Booking System 100 points) For this question, you will write several classes, and then create and use instances of those classes in order to simulate a hotel booking system. Note that in addition to the required methods below, you are free to add as many other private methods as you want (no additional public method is allowed). (a) (20 points) Write a class Room. A Room has the following private attributes: . A String type The Room class also contains the following public methods: . A constructor that takes as input the type of the room and uses it to initialize the attributes. Note that there are only 3 type of Rooms supported by the program: double, queen, and king. If the input is not one of these types, then the constructor should throw an IllegalArgumentEx- ception explaining that no room of such type can be created. The price of the room is based on its type as follows: $90 for a double, $110 for a queen, $150 for a king. The constructor should set the availability for a new room to be true. . getPrice which returns the price of the room. . getAvailability which returns the availability of the room. changeAvailability which takes no input and sets the value stored in the availability attribute to be the opposite of the one currently there. . A findAvailableRoom method which takes as input an array of Rooms as well as a String indicating the room type. The method should return the first available room in the array of the indicated type. If no such room exists (either because all rooms of said type are occupied, or because no room of such type is in the array), the method returns null. (b) (10 points) Write a class Reservation. A Reservation has the following private attributes: .A String name A Room roomReserved The Reservation class also contains the following public methods: . A constructor that takes as input a Room and the name under which the reservation is made. getName which returns the name under which the reservation was made. getRoom which returns the Room that has been reserved. (c) (40 points) Write a class Hotel. This class has three private attributes: . A String name . An array of Roos . An array of Reservation It also has the following methods

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_2

Step: 3

blur-text-image_3

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

Datacasting How To Stream Databases Over The Internet

Authors: Jessica Keyes

1st Edition

007034678X, 978-0070346789

More Books

Students also viewed these Databases questions