Ever stop to wonder what’s in a simple day like today? There’s no guarantee that today will bring about anything substantial. In fact, today could be a big flop on the ground and no one would notice. I don’t know how any of that tends to work out though. It’s life right? Oh life, what are you even on about? I don’t understand you at times. It would be nice to be able to grasp something, even if it’s out of thin air, to understand and realize what that’s all about. But alas I cannot do that. It is life after all, and we cannot really understand anything that comes our way. If I had the ability to realize my own potential, I think I could benefit from it all. But I don’t know how to do that. It’s a shame really, to want to be able to do something with this life and then to be stuck without any reason for it? Yeah, no bueno.
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