Total members 11894 |It is currently Fri Nov 22, 2024 4:11 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





I'm trying to code up a hotel.java program to check in guests and check out guests according to the following criteria:
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.
java code
/**
Brent Krise
Project 2 Hotel.java
February 2, 2009
*/

public class Hotel{

//for reading from the console
public static final java.util.Scanner INPUT
= new java.util.Scanner(System.in);

//data members
int floors;
int roomsperfloor;
int rooms;
String name;

//field holding name and room number
private String[][] squares;

//constructor: brings in the #floors and #rooms per floor
Hotel(int floors, int roomsperfloor){
this.floors = floors;
this.roomsperfloor = roomsperfloor;
}

//constructor: brings in 3 floors and 10 rooms per floor
Hotel(){
this.floors = 3;
this.roomsperfloor = 10;
}

//method for checking guests in
public boolean checkIn(String name, int room){

}

//method for checking guests out
public void checkOut(int room){

}

//method for checking if the hotel is full or not
public boolean isFull(){

}

//method for exiting the program
public void quit(){
return;
}

//check if the hotel meets the requirements
public boolean valid(){
if(rooms < 1 || rooms > 99 || floors < 1 || floors > 10){
System.out.println("This hotel doesn't meet the standards");
return false;
}else{
return true;
}
}

//main method
public static void main(String[]args){
System.out.println("How many floors in the hotel?");
floors = INPUT.nextInt();
System.out.println("How many rooms per floor?");
roomsperfloor = INPUT.nextInt();
Hotel h = new Hotel();
while (valid){
System.out.println(" 1. For checking a guest in");
System.out.println(" 2. For checking a guest out");
System.out.println(" 3. To quit");
if (INPUT.nextInt() == 1 && !isFull()){
h.checkIn();
}else if(INPUT.nextInt() == 2){
h.checkOut();
}else{
h.quit();
}
}

}
}

Here is the code I have so far, any help would be great




Attachments:
Hotel.java [1.82 KiB]
Downloaded 1699 times
Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time

do you have a specific problem

_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time

I'm working on a similar hotel project in my spare time. thanks for the post - it was helpful to see what you've done..


Author:
Newbie
User avatar Posts: 2
Have thanks: 0 time
Post new topic Reply to topic  [ 3 posts ] 

  Related Posts  to : Working on hotel class
 application on hotel management system     -  
 javap is not working     -  
 SSI.php on other websites, Not working     -  
 Define class helper class to check the method existance     -  
 ScrollableTable is not working in the firefox     -  
 jsp include directive not working     -  
 video conference is nt working     -  
 HELP: JAVA not working in TEXTPAD     -  
 working of bitwise ~ operator     -  
 java abstract class,concrete class and interface     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com