Exemple #1
0
        static void GetFreeTaxi(TaxiStation footInHands, ref List <Car> tmpCarsList)
        {
            LoggerMaster.LoggerM.Debug("In class: " + nameof(Program) + " : " + "Try call: " + MethodBase.GetCurrentMethod());

            string tmp;

ask1_loop:
            Console.Write("Курящий салон: y/n? : ");
            tmp = Console.ReadLine().ToLower();
            bool smoke = false;

            if (tmp == "y")
            {
                smoke = true;
            }
            else if (tmp == "n")
            {
                smoke = false;
            }
            else
            {
                Console.WriteLine("Недопустимый ответ.");
                goto ask1_loop;
            }

ask2_loop:
            Console.Write("Есть животные: y/n? : ");
            tmp = Console.ReadLine().ToLower();
            bool animals;

            if (tmp == "y")
            {
                animals = true;
            }
            else if (tmp == "n")
            {
                animals = false;
            }
            else
            {
                Console.WriteLine("Недопустимый ответ.");
                goto ask2_loop;
            }

ask3_loop:
            byte childs;

            try
            {
                Console.Write("Количество детских мест: ");
                childs = Convert.ToByte(Console.ReadLine());
            }
            catch (FormatException)
            {
                Console.WriteLine("Недопустимое значение.");
                goto ask3_loop;
            }
            catch (OverflowException)
            {
                Console.WriteLine("Недопустимое значение.");
                goto ask3_loop;
            }

            Taxi.CarClases cCl;
            Console.Write("Класс авто: BASE(1)/STANDARD(2)/PREMIUM(3) : ");
            string ccla = Console.ReadLine().ToLower();

            if (ccla == "1" || ccla == "base")
            {
                cCl = Taxi.CarClases.Base;
            }
            else if (ccla == "2" || ccla == "standard")
            {
                cCl = Taxi.CarClases.Standard;
            }
            else if (ccla == "3" || ccla == "premium")
            {
                cCl = Taxi.CarClases.Premium;
            }
            else
            {
                cCl = Taxi.CarClases.Base;
                Console.WriteLine("Класс не определен. Выбран класс BASE.");
            }

            tmpCarsList = footInHands.GetFreeTaxi(smoke, childs, animals, cCl);

            LoggerMaster.LoggerM.Debug("In class: " + nameof(Program) + " : " + "Was called: " + MethodBase.GetCurrentMethod());
        }