Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem Statement (Summary): You are going to develop a simple application for Hotels. Hotel is, actually, a Building, with some extra features. Each hotel as

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

Problem Statement (Summary): You are going to develop a simple application for Hotels. Hotel is, actually, a Building, with some extra features. Each hotel as a couple of rooms. Each room, has some features, including its own calendar, to keep its reservation records. To implement and test this system, you must create six Java classes as follows: Class Person (4 marks): Open the Java file Person.java that is provided. Later on, you must use this class in Reservation and Hotel classes. Complete this Java class using the following specifications: . Every person has first and last names. (1 mark) A constructor, which gets two parameters, first and last names, and initializes the corresponding instance variables. (1 mark) Override the toString method, such that it returns first and last names with one space in between. (2 marks) Class Building (4 marks): Open the Java file Building.java that is provided. Complete this Java class using the following specifications: . Every building has year of built and number of floors. (1 mark) A default constructor, which initializes the year of built to the current year, and floor to 1. Note that current year must not be hard coded, like 2021. (2 marks) Another constructor with two parameters, year of built and floor, which initializes the corresponding instance variables. (1 mark) . . O Class Reservation (15 marks): Open the Java file Reservation.java that is provided. The purpose of this class is to keep the record of each reservations of a room. Later on, you must use this class inside the Room class. Complete this Java class using the following specifications: Every reservation instance object has (6 marks) o start date and end date (Hint: Use Date class for the type of these two instance variables. Date is a class inside java.sql package.) o price per night o guest (Hint: Type of this instance variable should be Person) reservation number (The first reservation number must be 10001. Therefore, you must have a class-level variable that keeps the last reservation number used.) A constructor with four parameters, start date, end date, price, and guest. Note that you must set the reservation number for this reservation in this constructor as well. (1 mark) Getter methods for the start date, end date and the reservation number. (3 marks) A method, available, which gives start date (inclusive) and end date (exclusive) and will check if the room is available during these dates or not. (3 marks) Override the toString method, such that it returns a string including the reservation number, start and end dates, guest, and price, with the format like example below. (2 marks) Reservation Number: 10002. From: 2021-02-27 To: 2021-02-28, Guest: Maria Aunt, $35.5 per night. . 3 Class Room (27 marks): Open the Java file Room.java that is provided. The purpose of this class is to keep the record of each room of a given hotel. Later on, you must use this class inside the Hotel class. Complete this Java class using the following specifications: . (2 marks) First define an enum, named RoomType, with four possible values: SINGLE, DOUBLE, STUDIO, SUITE o Room type O 0 O Every room instance object has (8 marks) (Hint: use enum you defined for the type of this variable.) o price per night room size floor number room number o description vacancy status O ArrayList of all its reservations A constructor with six parameters, room type, price, size, room number, floor, and description. Note that you must also initialize the vacancy status and the list of reservations. (3 marks) Getter methods for the vacancy status, room number, price, and list of the reservations. (2 marks) A setter method for the price. (1 mark) O . A method, reserve, which gives start date (inclusive), end date (exclusive), and guest, and will reserve the room. Note that the room availability should be checked in this method. If it is available, then it reserves the room and returns the reservation number, and otherwise returns zero. (3 marks) A method, cancel, which gives a reservation number and will cancel that reservation. (2 marks) Two methods, checkin and checkout, to set the vacancy type of the room, accordingly. (2 marks) A method, status, which returns a string including the list of all the reservations of the room, with a format like example below. (2 marks) Reservation list of room number 102: Vacant. Reservation Number: 10001. From: 2021-03-21 To: 2021-03-24, Guest: Joe Uncle, $50.5 per night. Reservation Number: 10002. From: 2021-04-02 To: 2021-04-04, Guest: Lu Brother, $52.0 per night. Override the toString method, such that it returns a string including the room information, with the format like example below. The last part of the following example is the room description. (2 marks) SINGLE, price=$35.5, Size=200.0, Number=101, Floor=1, Single Room without view Class Hotel (30 marks): Open the Java file Hotel.java that is provided. Note that every hotel is a building with some extra features. You must consider this fact in the implementation of the class Hotel. Complete this Java class using the following specifications: Every hotel has (4 marks) O name rate O O one or more owners one or more rooms Provide the default constructor for the class, which only calls the default constructor of its superclass. (1 mark) Provide the second constructor for the class, with five parameters, hotel name, list of the hotel owners, year of built, number of floors, and hotel rate, which initializes the corresponding instance variables. Note that the proper constructor of the superclass must be called in this constructor. Also, the list of the hotel rooms must be initialized. (4 marks) Provide getter methods for hotel name and owners. (2 marks) Provide a getter method, getRooms, which returns the list of the hotel rooms as an ArrayList of rooms. (1 mark) Provide a getter method, getRoom, with one parameter, room number, which returns the corresponding room as its return type, and otherwise null. (1 mark) Provide a method, addowner, which adds one owner to the hotel's owners list. (1 mark) Provide a method, addRoom, which adds a new room to the hotel. (1 mark) . . Provide a method, reserve, with four parameters, room number, start date, end date, and guest. It will first find the room using one of the above methods. If it finds the room, then it simply calls the reserve method of that room, receives the reservation number and returns it. If the room is not found, it returns zero, which means the reservation was not successful. (4 marks) Provide a method, cancel, with one parameter, reservation number. It should find the room that has this reservation numbers. If it finds the room, then it will call the cancel method of that room with the reservation number given, and then returns true. Otherwise, it returns false, which means the cancellation was not successful. (3 marks) Override the toString method, such that it returns a string including the hotel information, with the format like example below. It shows the hotel information, followed by the rooms' information. (3 marks) Hotel Baba Mama, 3.5 stars. Hotel Owners: Ali Baba Alice Mama Rooms: SINGLE, price=$35.5, Size=200.0, Number=101, Floor=1, Single Room without view DOUBLE, price=$50.5, Size=350.0, Number=102, Floor=1, Double Room without view DOUBLE, price=$55.0, Size=400.0, Number=201, Floor=2, Double Room with view SUITE, price=$80.0, Size=500.0, Number=202, Floor=2, Suite Room with view and balcony Provide standard Java Documentation for all the public methods as well as one brief explanation for the Hotel class at the top of the class. Note that your documentation must follow the correct syntax of Java Documentation and not just simple comments

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

More Books

Students also viewed these Databases questions