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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

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 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 A double price A boolean availability 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, S110 for a queen, $150 for a king. The constructor should set the availability for a new room to be true getType which returns the type of the room 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. The constructor must use its inputs to initialize the attributes getName which returns the name under which the reservation was made o 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 Room An array of Reservation 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 A double price A boolean availability 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, S110 for a queen, $150 for a king. The constructor should set the availability for a new room to be true getType which returns the type of the room 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. The constructor must use its inputs to initialize the attributes getName which returns the name under which the reservation was made o 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 Room An array of Reservation 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

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

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions