If there’s one thing I don’t quite understand about this life, is why must it be this way? I mean, we have to deal with some things in life and we cannot easily allow them to be what they want to be, at least I don’t think that’s how it works. If it did? Then everything would be fine, we could continue on about whatever we wanted to do and there would be no harm or foul. That’s the problem with this life though. Nothing ever fully makes sense at times and we are left holding the problem end of the cord. There are times when life will come clean with us, we don’t always get that kind of protection mind you. So what do we end up doing? Do we want to keep thinking and going on about whatever there is to go on about? I’m not sure that’s a safe course of action. Hell, what is safe anymore? I do not know. What I do know is life will continue to be the way it’s meant to be. There’s no stopping it. No matter what happens in this life, we will always be stuck with whatever we’re meant to be st...
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