The code posted thus far won't work, but what follows is a rough framework that will at least get you started. Hopefully.
Code:
public class MyApplication {
public MyApplication() {
}
public static void main(String[] arguments) {
MyApplication application = new MyApplication();
application.start();
}
public void start() {
java.io.Reader reader = new java.io.InputStreamReader(System.in);
while (true) {
int input;
try {
input = reader.read();
} catch (java.io.IOException ioe) {
System.out.println("An unexpected error occurred whilst reading input.");
return;
}
switch (input) {
case 'e':
return;
case 'g':
/* ... */
break;
case 'l':
/* ... */
break;
case 's':
/* ... */
break;
default:
/* ... */
break;
}
}
}
}
Bookmarks