Ejemplo n.º 1
0
 static void Main(string[] args)
 {
     try
     {
         ConsoleUserInterface.Start();
         ConsoleUserInterface.Flight();
         Console.WriteLine();
     }
     catch (Exception e)
     {
         ConsoleUserInterface.PrintFlightInfo();
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(e.Message);
         Console.WriteLine("Полет завершен неудачно.");
         Console.ResetColor();
     }
     finally
     {
         Console.WriteLine("Завершение работы программы.\n");
     }
 }
Ejemplo n.º 2
0
 static void Main(string[] args)
 {
     try
     {
         ConsoleUserInterface.Start();
         ConsoleUserInterface.Flight();
         Console.WriteLine();
     }
     catch (Exception e)
     {
         ConsoleUserInterface.PrintFlightInfo();
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(e.Message);
         Console.WriteLine("Flight failed.");
         Console.ResetColor();
     }
     finally
     {
         Console.WriteLine("The completion of the program.\n");
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Управляет процессом полета, выполняя указания пользователя (пилота)
        /// </summary>
        public static void Flight()
        {
            do
            {
                switch (ConsoleUserInterface.GetCommand())
                {
                case UserCommands.SpeedUp:
                    Aircraft.Speed += 50;
                    break;

                case UserCommands.SpeedUpFast:
                    Aircraft.Speed += 150;
                    break;

                case UserCommands.SpeedDown:
                    Aircraft.Speed -= 50;
                    break;

                case UserCommands.SpeedDownFast:
                    Aircraft.Speed -= 150;
                    break;

                case UserCommands.AltitudeUp:
                    Aircraft.Altitude += 250;
                    break;

                case UserCommands.AltitudeUpFast:
                    Aircraft.Altitude += 500;
                    break;

                case UserCommands.AltitudeDown:
                    Aircraft.Altitude -= 250;
                    break;

                case UserCommands.AltitudeDownFast:
                    Aircraft.Altitude -= 500;
                    break;

                case UserCommands.AddDispatcher:
                    Console.Write("Введите имя нового диспетчера: ");
                    string name = Console.ReadLine();
                    Aircraft.AddDispatcher(name);
                    break;

                case UserCommands.RemoveDispatcher:
                    Console.Write("Введите номер удаляемого диспетчера: ");
                    int index = Convert.ToInt32(Console.ReadLine());
                    Aircraft.RemoveDispatcher(index - 1);
                    break;

                case UserCommands.Exit:
                    Console.WriteLine("Полет не завершен.");
                    return;
                }

                ConsoleUserInterface.PrintFlightInfo();
            } while (!Aircraft.Landed);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Полет успешно завершен!");
            Console.ResetColor();
            return;
        }
Ejemplo n.º 4
0
        public static void Flight()
        {
            do
            {
                switch (ConsoleUserInterface.GetCommand())
                {
                case UserCommands.SpeedUp:
                    Aircraft.Speed += 50;
                    break;

                case UserCommands.SpeedUpFast:
                    Aircraft.Speed += 150;
                    break;

                case UserCommands.SpeedDown:
                    Aircraft.Speed -= 50;
                    break;

                case UserCommands.SpeedDownFast:
                    Aircraft.Speed -= 150;
                    break;

                case UserCommands.AltitudeUp:
                    Aircraft.Altitude += 250;
                    break;

                case UserCommands.AltitudeUpFast:
                    Aircraft.Altitude += 500;
                    break;

                case UserCommands.AltitudeDown:
                    Aircraft.Altitude -= 250;
                    break;

                case UserCommands.AltitudeDownFast:
                    Aircraft.Altitude -= 500;
                    break;

                case UserCommands.AddDispatcher:
                    Console.Write("Enter the name of the new dispatcher: ");
                    string name = Console.ReadLine();
                    Aircraft.AddDispatcher(name);
                    break;

                case UserCommands.RemoveDispatcher:
                    Console.Write("Enter the number of the dispatcher to be deleted: ");
                    int index = Convert.ToInt32(Console.ReadLine());
                    Aircraft.RemoveDispatcher(index - 1);
                    break;

                case UserCommands.Exit:
                    Console.WriteLine("The flight is not completed.");
                    return;
                }

                ConsoleUserInterface.PrintFlightInfo();
            } while (!Aircraft.Landed);

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Flight completed successfully!");
            Console.ResetColor();
            return;
        }