public static void Main(string[] args) { var chronometer = new Chronometer(); while (true) { var command = Console.ReadLine(); switch (command) { case "start": chronometer.Start(); break; case "stop": chronometer.Stop(); break; case "lap": Console.WriteLine(chronometer.Lap()); break; case "laps": Console.WriteLine(chronometer.GetLaps()); break; case "time": Console.WriteLine(chronometer.GetTime); break; case "reset": chronometer.Reset(); break; case "exit": Environment.Exit(0); break; default: break; } } }
public static void Main() { var chronometer = new Chronometer(); var appIsRunning = true; while (appIsRunning) { var command = Console.ReadLine(); switch (command) { case "start": chronometer.Start(); break; case "stop": chronometer.Stop(); break; case "lap": Console.WriteLine(chronometer.Lap()); break; case "laps": Console.WriteLine(chronometer.GetLaps()); break; case "time": Console.WriteLine(chronometer.GetTime); break; case "reset": chronometer.Reset(); break; case "exit": appIsRunning = false; break; } } }
static void Main(string[] args) { var chronometer = new Chronometer(); var command = string.Empty; while ((command = Console.ReadLine()) != "exit") { var result = chronometer .GetType() .GetMethod(Char.ToUpper(command[0]) + command.Substring(1)) .Invoke(chronometer, null); if (result == null) { continue; } Console.WriteLine(result); } }