I don’t want to think Jun 13, 2019 There are days where I simply don’t want to think. I don’t want to have to think about anything. Is that wrong? I’m not sure. Is that okay? Nope, still not sure. It would be nice to be able to figure out everything that occurs in this life and yet here we all are, hoping something will happen. yet we simply don’t know or fully understand what will happen or when that will occur. So that’s life right now. Just deal with it I suppose.
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