-
Notifications
You must be signed in to change notification settings - Fork 4
Assignment 1 Sec 3
This assignment requires you to implement at least two classes. The first class, Room, models a basic room-object from the administrative point of view. The second class, Hotel, implements methods for administering/managing room objects. The main method in the Hotel class creates and manipulates Room objects using an array structure for this.
Friday, September 6th at 11:59 P.M. HST
Create a project consisting of at least two classes. These two classes will be Room.java and Hotel.java. You may add other classes if you consider them necessary. However you must have these two classes and they must work as it is described in this specification. You must add comments to all your classes and methods.
The name of the classes should be Room.java and Hotel.java.
Attach a jar file of the contents of your source code to achriste@hawaii.edu with the subject
assignment/090613
See Assignment Policy for more information.
/**
* The room number.
* This hotel has 20 rooms per floor. Rooms are numbered from 101 to 120 in the first floor,
* from 201 to 220 in the second floor and so on. The hotel has 8 floors so the last room number is 820.
* You should validate accordingly.
*/
private int roomNumber;
/**
* The has a flag/boolean variable to determine if it is currently occupied.
* If this flag is true, the room is occupied, otherwise it is false.
*/
private boolean isOccupied;
/**
* The guest name is stored here.
* If the room is vacant, then this should be an empty String.
*/
private String guest;
/**
* The cost per day is stored here.
* Room prices can not be negative. They can be zero for complementary stays.
* There is no limit for max cost.
*
* Price should be there at all times. Standard rooms price is $200. Rooms at or above the 5th floor
* cost $350 per night.
*/
private double costPerDay;
/**
* The number of days that the guest will be staying in the hotel.
* When the room is not occupied, this value should be zero. When the guest registers, the value
* of this field should be positive.
*/
private int days;All of the getters:
- getRoomNumber
- getIsOccupied
- getGuest
- getCostPerDay
- getDays
The following setters:
- setIsOccupied
- setDays
- setGuest
An overriden toString method which formats the output in the following way
| If the room is occupied | If the room is unoccupied |
|---|---|
| The following data, one per line: room number, guest name, cost per day, days | The following data, all on one line: room number and cost per day |
Create a text based menu system that should present the following options when the program starts:
- Guest registration
- Guest checkout
- Print list of occupied rooms
- Exit
Create an array of rooms with the standard Room.java values. There are several ways in which you can engineer your array so I will not give specific directions on it. Go ahead and design your own. At the beginning, the hotel must be empty.
When a guest arrives, you will as for the following information
- Name
- Days staying
- Floor preference. Zero will be the option for "no preference".
Your program should show the list of available rooms at the preferred floor. If the guest has no preference you should get a list of all the available rooms in the hotel. You should then pick one of the available rooms.
Once you have selected the room number, you should assign the guest to the room by storing his/her information into the array.
Your hotel program should loop by going back out in to the main menu.
- Calculate the guest's bill by multiplying the number of days stayed by the cost per day.
- Print to the screen the room number, guest name, days stayed, and total cost.
- Reset the room to be empty as specified above.
- Print the occupied rooms from the array of rooms
- Arrays: You should have an array of Room objects. You should not use any other data structure but ONE array (only one).
- Exception Handling: Use try/catch. Your program should not crash.
If you have any questions about this assignment, please contact achriste@hawaii.edu