예제 #1
0
파일: Program.cs 프로젝트: Maxim4iik/Labs
        static void Main(string[] args)
        {
            Console.WriteLine("hello world");

            Console.Write("enter car acceleration: ");
            double acceleration = double.Parse(Console.ReadLine());

            Console.Write("enter car speed limit: ");
            double speedLimit = double.Parse(Console.ReadLine());

            Car car = new Car(acceleration, speedLimit);

            car.StartRiding        += OnStartRiding;
            car.StopRiding         += OnStopRiding;
            car.SpeedLimitExceeded += OnSpeedLimitExceeded;

            while (true)
            {
                Console.WriteLine();
                Console.WriteLine("options:");
                Console.WriteLine("  1) Ride");
                Console.WriteLine("  2) Stop");
                Console.WriteLine("  3) Tick");
                Console.WriteLine("  4) Exit");

                Console.Write("i want to: ");
                int option = int.Parse(Console.ReadLine());

                if (option == 4)
                {
                    Console.WriteLine("bye");
                    break;
                }

                switch (option)
                {
                case 1:
                    car.Ride();
                    break;

                case 2:
                    car.Stop();
                    break;

                case 3:
                    car.Tick();
                    break;

                default:
                    Console.WriteLine("invalid option");
                    break;
                }
            }

            Console.ReadKey();
        }