I am trying to create a small Hotel application with a menu system. So far the user is asked for a room number (0-9) and a room name, once this is entered I want the user to be returned to the menu where the other menu options can be entered. I don't think the other menu options are working currently either :(
Here is my code so far:
package hotel;
import java.util.*;
public class Hotel2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Room[] myHotel = new Room[10];
myHotel[0] = new Room ();
myHotel[1] = new Room ();
myHotel[2] = new Room ();
myHotel[3] = new Room ();
myHotel[4] = new Room ();
myHotel[5] = new Room ();
myHotel[6] = new Room ();
myHotel[7] = new Room ();
myHotel[8] = new Room ();
myHotel[9] = new Room ();
String roomName;
String menuEntry = null;
int roomNum = 0;
String[] hotel = new String[11];
for (int x = 0; x < 10; x++ ) hotel[x] = "";
initialise(hotel);
while ( roomNum < 10 )
{
System.out.println("Please enter one of the following options:\n1) Add customer\n2) Delete customer from room\n3 )View all empty rooms\n4) Find a customer\n5) Load program from text file\n6) Order rooms alphabetically\n7) Store program into text file\n8) View all rooms\nInput:");
menuEntry = input.next();
while (menuEntry.equals("1"))
{
System.out.println("Enter room number (0-9):" );
roomNum = input.nextInt();
if (roomNum < 10)
{
System.out.println("Enter name for room " + roomNum +" :" ) ;
roomName = input.next();
hotel[roomNum] = roomName ;
}
}
if (menuEntry.equals("V"))
{
for (int x = 0; x < 10; x++ )
{
System.out.println("room " + x + " occupied by " + hotel[x]);
}
}
if (menuEntry.equals("E"));
{
}
if (menuEntry.equals ("D"))
{
System.out.println("Enter the room number which you would like to delete a customer from:");
roomNum = input.nextInt();
hotel[roomNum] = "empty";
}
}
}
private static void initialise( String hotelRef[] ) {
for (int x = 0; x < 10; x++ ) hotelRef[x] = "empty";
System.out.println( "initilise\n");
}
}