package ru.toster.java.q241826;
import java.util.Date;
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
while (true) {
System.out.print("enter command>");
String command = scnr.nextLine();
if ("help".equals(command)) {
printListCommand();
} else if ("date".equals(command)) {
printDate();
} else if ("time".equals(command)) {
printTime();
} else if ("exit".equals(command)) {
System.out.println("Good Bye!");
break;
} else {
System.out.println("Unknown command! Please enter 'help'");
}
}
scnr.close();
}
private static void printTime() {
System.out.printf("%1tT\n", new Date());
}
private static void printDate() {
System.out.printf("%1tY-%1$tm-%1$td\n", new Date());
}
private static void printListCommand() {
System.out.println(
"'help'\tprint list commands;\n" +
"'exit'\texit from programm;\n" +
"'date'\tprint today's date;\n" +
"'time'\tprint current time;");
}
}
// Variant 1
class Lol {
public void main(String[] args) {
while(true) {
// prog code
// ввод от пользователя. Если символ не тот -- break
}
}
}
// Variant 2
class Lol2 {
public void main(String[] args) {
// prog code
// ввод от пользователя. Если символ тот -- this.main(args)
}
}