111 lines
2.2 KiB
Java
111 lines
2.2 KiB
Java
package de.ctdo.crashtest;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.InputStreamReader;
|
|
import java.nio.CharBuffer;
|
|
|
|
public class Steuerung {
|
|
|
|
private static enum STATE {
|
|
IDLE,
|
|
ROOM_ENTERED,
|
|
TABLE_GAME,
|
|
}
|
|
private STATE current_state = STATE.IDLE;
|
|
|
|
|
|
public static void main(String args[]) {
|
|
|
|
//new Steuerung().run();
|
|
|
|
new SteuerungFrame();
|
|
|
|
}
|
|
|
|
public void FlushInputBuffer() {
|
|
int TempValue = 0;
|
|
|
|
do {
|
|
try {
|
|
TempValue = System.in.read();
|
|
}
|
|
catch (java.io.IOException e) {
|
|
}
|
|
} while (TempValue != 10);
|
|
}
|
|
|
|
public char GetChar() {
|
|
int ReadValue = 0;
|
|
|
|
try {
|
|
ReadValue = System.in.read();
|
|
}
|
|
catch (java.io.IOException e) {
|
|
}
|
|
|
|
this.FlushInputBuffer();
|
|
|
|
return (char) ReadValue;
|
|
}
|
|
|
|
public void run() {
|
|
boolean doRun = true;
|
|
//BufferedReader in = new BufferedReader(new InputStreamReader( System.in ) );
|
|
InputStreamReader in = new InputStreamReader(System.in);
|
|
|
|
while(doRun) {
|
|
char[] buffer = new char[100];
|
|
|
|
try {
|
|
|
|
char c = GetChar();
|
|
|
|
System.out.println("char = " + c);
|
|
|
|
//if(command.equals("exit") || command.equals("quit")) doRun = false;
|
|
|
|
//handleCommand(command);
|
|
|
|
|
|
|
|
Thread.sleep(200);
|
|
|
|
// } catch (IOException e) {
|
|
// e.printStackTrace();
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
|
|
System.out.println("Current state after: " + current_state);
|
|
}
|
|
}
|
|
|
|
private void handleCommand(String command) {
|
|
System.out.println("Current state before: " + current_state);
|
|
|
|
switch (current_state) {
|
|
case IDLE:
|
|
|
|
if(command.equals("c")) {
|
|
current_state = STATE.ROOM_ENTERED;
|
|
}
|
|
|
|
break;
|
|
case ROOM_ENTERED:
|
|
|
|
break;
|
|
case TABLE_GAME:
|
|
|
|
|
|
break;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|