75 lines
1.8 KiB
Java
75 lines
1.8 KiB
Java
import java.util.Scanner;
|
|
|
|
|
|
public final class EscapeRoom {
|
|
|
|
public static void main(String[] args) {
|
|
EscapeRoom er = new EscapeRoom();
|
|
er.addRoom(new GuessTheNumberRoom());
|
|
er.play();
|
|
}
|
|
|
|
private Queue<Room> rooms;
|
|
|
|
private long startTime;
|
|
|
|
private Scanner input;
|
|
|
|
public EscapeRoom() {
|
|
rooms = new Queue<Room>();
|
|
input = new Scanner(System.in);
|
|
}
|
|
|
|
public void addRoom( Room r ) {
|
|
rooms.enqueue(r);
|
|
}
|
|
|
|
public void play() {
|
|
startTime = System.currentTimeMillis();
|
|
System.out.println("Willkommen im Escape Room!");
|
|
System.out.println("Die erste Herausforderung erwartet dich!");
|
|
|
|
while( !rooms.isEmpty() ) {
|
|
rooms.front().play(this);
|
|
rooms.dequeue();
|
|
}
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
int finalTime = (int) ((endTime-startTime) / (1000));
|
|
System.out.println("Du bist entkommen!");
|
|
System.out.printf("Du hast %d Sekunden gebraucht!\n", finalTime);
|
|
}
|
|
|
|
public int askForInt( String pText ) {
|
|
System.out.print(pText+" ");
|
|
return input.nextInt();
|
|
}
|
|
|
|
public boolean askForBool( String pText ) {
|
|
System.out.print(pText+" ");
|
|
return input.nextBoolean();
|
|
}
|
|
|
|
public String askForString( String pText ) {
|
|
System.out.print(pText+" ");
|
|
return input.nextLine();
|
|
}
|
|
|
|
public void print( String pText ) {
|
|
System.out.print(pText);
|
|
}
|
|
|
|
public void println( String pText ) {
|
|
System.out.println(pText);
|
|
}
|
|
|
|
public void wait( int milli ) {
|
|
try {
|
|
Thread.sleep(milli);
|
|
} catch( InterruptedException ex ) {
|
|
// Ignore
|
|
}
|
|
}
|
|
|
|
}
|