Why must life be this way? I don’t understand it. If we lived in a utopia, things might be better; but I’m not sure about that. I wish there was some kind of something to overcome this feeling of inadequacy. I doubt I will ever fully figure it out. If I had the ability, I would do it in a second. But I don’t seem to have that ability at the moment. Maybe one day I will be able to figure it all out.
Here we have a simple do/while loop with the input from a Scanner going to a switch statement.
import java.util.Scanner;
import java.util.Date;
public class Test {
public static void main(String[] args) {
Action action = new Action();
Scanner scanner = new Scanner(System.in);
String in;
do {
System.out.print("> ");
in = scanner.nextLine();
action.process(in);
} while (!in.equals("quit"));
}
}
class Action {
public Action() {
}
public void process(String in) {
switch(in) {
case "date": date(); break;
}
}
public void date() {
System.out.println(new Date().toString());
}
}
Comments
Post a Comment