Beispiel #1
0
 private static void SetPower(Lorry lorry)
 {
     try
     {
         lorry.Power = Convert.ToInt32(Console.ReadLine());
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите мощность двигателя заново.");
     }
 }
Beispiel #2
0
 private static void SetManufacturer(Lorry lorry)
 {
     try
     {
         lorry.Manufacturer = Console.ReadLine();
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите марку грузовика заново.");
     }
 }
Beispiel #3
0
 private static void SetCylinderCount(Lorry lorry)
 {
     try
     {
         lorry.CylinderCount = Convert.ToInt32(Console.ReadLine());
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите количество цилиндров двигателя заново.");
     }
 }
Beispiel #4
0
 private static void SetCarrying(Lorry lorry)
 {
     try
     {
         lorry.Carrying = Convert.ToInt32(Console.ReadLine());
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите грузоподъёмность заново.");
     }
 }
Beispiel #5
0
        private static void Main()
        {
            Console.Title = "Лабораторная работа №2";
            var car = new Car();
            var lorry = new Lorry();

            string userInput;

            do
            {
                userInput = DisplayMenu();

                switch (userInput)
                {
                    case "1":
                        Console.Clear();
                        CarMenuLogic(car);
                        break;
                    case "2":
                        Console.Clear();
                        LorryMenuLogic(lorry);
                        break;
                    default:
                        Console.Clear();
                        Console.WriteLine("Неверный пункт меню.");
                        break;
                }
            } while (userInput != "3");
        }
Beispiel #6
0
        private static void LorryMenuLogic(Lorry lorry)
        {
            string userInput;
            do
            {
                userInput = DisplayLorryMenu();

                switch (userInput)
                {
                    case "1":
                        Console.Clear();
                        SetManufacturer(lorry);
                        break;
                    case "2":
                        Console.Clear();
                        SetCylinderCount(lorry);
                        break;
                    case "3":
                        Console.Clear();
                        SetPower(lorry);
                        break;
                    case "4":
                        Console.Clear();
                        SetCarrying(lorry);
                        break;
                    case "5":
                        Console.Clear();
                        lorry.Print();
                        break;
                    case "6":
                        Console.Clear();
                        break;
                    default:
                        Console.Clear();
                        Console.WriteLine("Неверный пункт меню.");
                        break;
                }
            } while (userInput != "6");
        }