Question: Create a new project in BlueJ. Create two new classes in the project, with the following specifications: Class name: Guest Fields : name (String) roomNumber

Create a new project in BlueJ. Create two new classes in the project, with the following specifications:

Class name: Guest

Fields:

  • name (String)
  • roomNumber (int)
  • checkOutDate (Date) Tip: Date is a class in java.util, so you will need to import java.util.Date.

Constructor: Write a default constructor (no parameters) that initializes the fields to the following default values:

  • name: "" (empty string)
  • roomNumber: 100
  • checkOutDate: new Date() Tip: new Date() creates a date object with the current date

Methods: Write getters and setters for all fields. The getters and setters should be named according to standard Java conventions. Add validation to the setRoomNumber method so that the room number is only updated if the given room number is valid. This hotel has two floors with rooms numbered 100 - 140 and 200 - 240.

Class name: Hotel

Fields:

  • name (String)
  • guests (ArrayList)

Constructor: takes one parameter, the hotel name, and initializes the name field; creates an empty list to initialize guests.

Methods: Write getters and setters for all fields. Name the getters and setters according to standard Java conventions.

Save the project as a jar file to submit.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!