コード例 #1
0
        static void Main()
        {
            TickTock time   = new TickTock();
            TooLate  die    = null;
            Stepan   stepan = null;


            bool wannaBreak = false;

            while (true)
            {
                Console.WriteLine(menu);
                string response = Console.ReadLine();
                int    result;
                if (int.TryParse(response, out result) && result >= 1 && result <= 6)
                {
                    switch (result)
                    {
                    case 1:
                        Console.WriteLine("Enter time in milliseconds");
                        string responsedTime = Console.ReadLine();
                        int    resultTime;
                        if (int.TryParse(responsedTime, out resultTime))
                        {
                            time.SetTheFinalCountDown(resultTime);
                        }
                        else
                        {
                            Console.WriteLine("Bad decision!");
                        }
                        break;

                    case 2:
                        die = new TooLate(time);
                        break;

                    case 3:
                        die?.Unregister(time);
                        break;

                    case 4:
                        stepan = new Stepan(time);
                        break;

                    case 5:
                        stepan?.Unregister(time);
                        break;

                    case 6:
                        wannaBreak = true;
                        break;
                    }
                    if (wannaBreak)
                    {
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Bad decision!");
                }
            }
        }