CSC234 - Project 2
Hotel Java

Assigned Feb 1st 1 p.m.
Due Feb 5th 1 p.m.


Overview

Write a Java program called Hotel.java to both provide a class to represent a hotel and a main method described below. This class should have at least one field, a String[][] holding the name of the person in each hotel room. (All of the rooms are singles.) Provide a constructor which brings in two ints, one for number of floors, one for rooms per floor, and a default constructor which creates a Hotel with 3 floors and 10 rooms per floor. Provide a method checkIn(String name, int room) that puts the named person in the specified room, if the room is currently empty. If the room was available, return true, but if the room is already occupied, return false. Provide a method checkOut(int room) to clear a room which returns nothing. Finally, provide a method isFull() which returns true if all of the rooms are occupied, otherwise false.

The main method of the program should ask the user for how many floors their hotel is, and then how many rooms per floor. There can be at most 99 rooms per floor, and at most 10 floors, and there must be at least one room and one floor per room. This input should be checked for validity; on invalid input the user should be reprompted. With this data for floors and rooms per floor, a Hotel object should be created.

The user is then repeatedly presented a menu which asks if they want to

  1. check a guest in
  2. check a guest out
  3. quit the program.
If the user says 1 and there are rooms available, prompt the user for a name and room number and attempt to add this guest to that room. Rooms are numbered such that the last two digits are the individual room number, and the preceeding digits specify the floor, such that room 305 is room 5 of the third floor, and 47 is room 47 on the zeroth floor. If this add is unsuccessful, prompt for a new room number. If there are no rooms available, notify the user of this case.

If the user says 2, prompt the user for a room number to vacate.

If the user says 3, exit the loop and finish the program.

What to turn in

  1. Hotel.java
To hand in your Project 2 files, follow the steps listed below from the Wright Lab computers:
  1. Open the Terminal application.
  2. SSH with ssh username@cs.centenary.edu to connect with the cs server.
  3. Type in your password.
  4. Make a new directory with mkdir csc234/project2
  5. Log out of the cs server with logout
  6. Change to the directory where you have your files on the local computer.
  7. Securely copy your files to your directory with scp filenames username@cs.centenary.edu:"csc234/project2"

© Mark Goadrich 2009, Centenary College of Louisiana