Esempio n. 1
0
        static Shape FillingBoxModel()
        {
            Console.WriteLine($"Какое тело добавить в Box?\n{(int)AddModels.Culynder} - цилиндр, {(int)AddModels.Pyramid} - пирамида, {(int)AddModels.Ball} - шар");
            string input = Console.ReadLine();

            if (int.TryParse(input, out int userInput))
            {
                if (AddModels.IsDefined(typeof(AddModels), userInput))
                {
                    AddModels addModel = (AddModels)userInput;
                    Shape     newModel = ValumeModel(addModel);
                    return(newModel);
                }
                else
                {
                    Console.WriteLine("Вы указали неизвестное тело =(");
                    Environment.Exit(0);
                }
            }
            else
            {
                Console.WriteLine("Вы указали неверное число =(");
                Environment.Exit(0);
            }

            return(null);
        }
        public ActionResult Models()
        {
            AddModels model = new AddModels();

            model.Makes  = _carRepository.GetMakes();
            model.Models = _carRepository.GetModels();
            model.Make   = new VMake();
            model.Model  = new VModel();
            return(View(model));
        }
Esempio n. 3
0
        static Shape ValumeModel(AddModels nameModel)
        {
            switch (nameModel)
            {
            case AddModels.Culynder:
            {
                Cylinder model = new Cylinder();
                Console.WriteLine("Введите, пожалуйста, высоту цилиндра и радиус основания цилиндра:");
                Console.Write("H = ");
                if (int.TryParse(Console.ReadLine(), out int h))
                {
                    model.Height = h;
                }
                else
                {
                    Console.WriteLine("Вы указали неверное значение =(");
                    Environment.Exit(0);
                }
                Console.Write("R = ");
                if (int.TryParse(Console.ReadLine(), out int r))
                {
                    model.Radius = r;
                }
                else
                {
                    Console.WriteLine("Вы указали неверное значение =(");
                    Environment.Exit(0);
                }

                return(model);
            }

            case AddModels.Pyramid:
            {
                Pyramid model = new Pyramid();
                Console.WriteLine("Введите, пожалуйста, площадь основания пирамиды и высоту:");
                Console.Write("S = ");
                if (int.TryParse(Console.ReadLine(), out int s))
                {
                    model.Area = s;
                }
                else
                {
                    Console.WriteLine("Вы указали неверное значение =(");
                    Environment.Exit(0);
                }
                Console.Write("H = ");
                if (int.TryParse(Console.ReadLine(), out int h))
                {
                    model.Height = h;
                }
                else
                {
                    Console.WriteLine("Вы указали неверное значение =(");
                    Environment.Exit(0);
                }

                return(model);
            }

            case AddModels.Ball:
            {
                Ball model = new Ball();
                Console.WriteLine("Введите, пожалуйста, радиус шара:");
                Console.Write("R = ");
                if (int.TryParse(Console.ReadLine(), out int r))
                {
                    model.Radius = r;
                }
                else
                {
                    Console.WriteLine("Вы указали неверное значение =(");
                    Environment.Exit(0);
                }

                return(model);
            }
            }
            return(null);
        }