For my CS course I have to program a hotel checkin/checkout system. The program must be able to check people in and out. The programm assigns the first available room to a guest upon checkin. If no room is free, it will say so as well. The Hotel has four rooms.
In the assignment it says there need to be 4 classes: Assignment5, Hotel, Room, & Guest.
Assignment5 class is for the interaction with the user.
Hotel class has four rooms and all methods for operating the rooms.
Room class has 1 guest. If the rooms is empty a guest can check in. If the guest is leaving the room needs to be emptied.
Guest class: the guest has a firstname and a last name.
In the menu there need to be 4 options: 1 show status of rooms available and occupation. 2 check in option 3 check out option 4 end program option.
OK, so I know I should make my assignment for myself. However, I don't know what it is, but starting with assignments I have great problems cutting the thing up in smaller pieces. Also this assignment is to learn working with different classes and I don't really understand which sequence of steps i should take in this case.
Can someone help me getting started by giving some tips? Have been staring at my screen for hours now and just thought I could use some little insights to get me started. Any help is greatly apprecieted!
OK thnks for the help so far.
**First of all, MANY thanks for all your help, you guys are great! Have been at it for 7 hours straight now and still stuck. My problem now is that it doesn't compile. It says:
Java:28: checkIn(Gast) in Hotel cannot be applied to (java.lang.String)
hotel.checkIn("Guido");
^
1 error
And maybe, can someone look if this way i put it now is a little bit on the right path? I do thank JavaGeek for his program, but i want to learn it by doing myself.
up until now I have the following:
import java.util.Scanner;
public class bopgave5 {
public static void main(String[] args) {
boolean opnieuw = false;
do {
int invoer = menu();
if (invoer == 2){
Hotel hotel = new Hotel();
hotel.checkIn("Guido");
opnieuw = true;
}
else if (invoer == 4)
opnieuw = false;
else
opnieuw = true;
}
while (opnieuw == true);
}
public static int menu (){
Scanner sc = new Scanner(System.in);
System.out.println("MENU: [1] Statusoverzicht");
System.out.println(" [2] Check-in");
System.out.println(" [3] Check-out");
System.out.println(" [4] Einde");
System.out.print("Uw invoer: ");
int invoer = sc.nextInt();
return invoer;
}
}
class Hotel {
Kamer kamer1, kamer2, kamer3, kamer4;
Hotel (){
kamer1 = new Kamer();
kamer2 = new Kamer();
kamer3 = new Kamer();
kamer4 = new Kamer();
}
void checkIn(Gast nieuweGast) {
if (kamer1.gast == null) {
kamer1.gast = nieuweGast;
System.out.println("Gast " + nieuweGast.naam + " krijgt kamer 1");
return;
}
else if (kamer2.gast == null) {
kamer2.gast = nieuweGast;
System.out.println("Gast " + nieuweGast.naam + " krijgt kamer 2");
return;
}
else if (kamer3.gast == null) {
kamer3.gast = nieuweGast;
System.out.println("Gast " + nieuweGast.naam + " krijgt kamer 3");
return;
}
else if (kamer4.gast == null) {
kamer4.gast = nieuweGast;
System.out.println("Gast " + nieuweGast.naam + " krijgt kamer 5");
return;
}
else {
System.out.println("hotel is vol");
return;
}
}
}
class Kamer {
Gast gast;
Kamer() {
gast = null;
}
}
class Gast {
String naam;
Gast(String nieuweNaam) {
naam = nieuweNaam;
}
}