예제 #1
0
파일: Program.cs 프로젝트: Ljubo6/SoftUni-1
        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;
                }
            }
        }
예제 #2
0
        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;
                }
            }
        }
예제 #3
0
        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);
            }
        }