示例#1
0
文件: Car.cs 项目: VulturRe/Lab2
 private static void SetPower(Lorry lorry)
 {
     try
     {
         lorry.Power = Convert.ToInt32(Console.ReadLine());
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите мощность двигателя заново.");
     }
 }
示例#2
0
文件: Car.cs 项目: VulturRe/Lab2
 private static void SetManufacturer(Lorry lorry)
 {
     try
     {
         lorry.Manufacturer = Console.ReadLine();
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите марку грузовика заново.");
     }
 }
示例#3
0
文件: Car.cs 项目: VulturRe/Lab2
 private static void SetCylinderCount(Lorry lorry)
 {
     try
     {
         lorry.CylinderCount = Convert.ToInt32(Console.ReadLine());
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите количество цилиндров двигателя заново.");
     }
 }
示例#4
0
文件: Car.cs 项目: VulturRe/Lab2
 private static void SetCarrying(Lorry lorry)
 {
     try
     {
         lorry.Carrying = Convert.ToInt32(Console.ReadLine());
     }
     catch (FormatException ex)
     {
         Console.WriteLine(ex.Message);
         Console.WriteLine("Введите грузоподъёмность заново.");
     }
 }
示例#5
0
文件: Car.cs 项目: VulturRe/Lab2
        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");
        }
示例#6
0
文件: Car.cs 项目: VulturRe/Lab2
        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");
        }