I am working on a program with two classes that is supposed to handle hotel information and am getting confused on how to work with an array properly. Here is my code so far:
public class Hotel {
Scanner scan = new Scanner (System.in);
public int[] HotelArr = new int [100];
public int num;//for menu
Hotel()
{
}
public void arrival()
{
Room myroom = new Room();
myroom.checkIn();
}
public void departure()
{
Room myroom = new Room();
myroom.checkOut();
}
public void taken()
{
//prints how many guests there are and how many rooms are filled
}
public void menu()
{
while (num !=4)
{
System.out.println("Type 1 for: Arrival");
System.out.println("Type 2 for: Departure");
System.out.println("Type 3 for: Taken");
System.out.println("Type 4 for: Exit");
num = scan.nextInt();
betMalon();
}
}
public void betMalon()
{
switch(num)
{
case '1': arrival();
break;
case '2': departure();
break;
case '3': taken();
break;
}
}
}
public class Room {
private int numppl;
private int daystay;
Scanner scan = new Scanner (System.in);
public void checkIn()
{
System.out.println("How many people will like to check in?");
numppl = scan.nextInt();
System.out.println("For how many days would you like to check in for?");
daystay = scan.nextInt();
}
public void checkOut()
{
//each person needs to pay $100 a day
int payperperson = 100 * daystay;
int entireroompay = payperperson * numppl;
System.out.println("Each person needs to pay: " + payperperson );
System.out.println("The entire room needs to pay: " + entireroompay);
//puts 0 for ppl staying in room
}
}
As you can see I have the basic code down I am just not sure how to handle putting ppl into rooms etc...
Thanks in advance for your help and guidance.