Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            Seat  seat  = new Seat("Leon", "Grey");
            Tesla tesla = new Tesla("Model 3", "Red", 2);

            Console.WriteLine(seat.ToString());
            Console.WriteLine(tesla.ToString());
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            ICar seat  = new Seat("Ibiza", "Black");
            ICar tesla = new Tesla("Fury", "White", 4);

            Console.WriteLine(seat);
            Console.WriteLine(tesla);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            ICar seat  = new Seat("Leon", "Grey");
            ICar tesla = new Tesla("Model 3", "Red", 2);

            Console.WriteLine(seat);
            Console.WriteLine(tesla);
        }
Ejemplo n.º 4
0
        public static void Main()
        {
            ICar seat  = new Seat("Leon", "Grey");
            ICar tesla = new Tesla("Model 3", "Red", 2);

            Console.WriteLine(seat.ToString());
            Console.WriteLine(tesla.ToString());
        }
Ejemplo n.º 5
0
        static void Main()
        {
            ICar seat = new Seat("Leon", "Grey");
            ICar tesla = new Tesla("Model S", "White", 4);

            Console.WriteLine(seat.ToString());
            Console.WriteLine(tesla.ToString());
        }
Ejemplo n.º 6
0
        public static void Run()
        {
            ICar seat  = new Seat("Leon", "Grey");
            ICar tesla = new Tesla("Model 3", "Red", 2);

            Console.WriteLine(seat);
            Console.WriteLine(tesla);
        }
Ejemplo n.º 7
0
        public static void Main(string[] args)
        {
            Seat NewSeat = new Seat("Leon", "Grey");

            Tesla newTesla = new Tesla("Model 3", "Red", 2);

            Console.Write(NewSeat);
            Console.Write(newTesla);
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            ICar seat  = new Seat("Ibisa", "red");
            ICar tesla = new Tesla("Model S", "white", 2);

            Console.WriteLine(seat.ToString());
            Console.WriteLine(tesla.ToString());

            Console.WriteLine(tesla.);
        }
Ejemplo n.º 9
0
        public void Proceed()
        {
            ICar seat  = new Seat("Leon", "Grey");
            ICar tesla = new Tesla("Model 3", "Red", 2);

            //ICar audi = new Audi("RS", "Mat");

            Console.WriteLine(seat);
            Console.WriteLine(tesla);
            //Console.WriteLine(audi);
        }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            ICar seat  = new Seat("Comfy 3000", "Space Black");
            ICar tesla = new Tesla(50000, "3", "Red");

            Console.WriteLine(seat.Start());
            Console.WriteLine(seat.Stop());
            Console.WriteLine(seat);
            Console.WriteLine(tesla.Start());
            Console.WriteLine(tesla.Stop());
            Console.WriteLine(tesla);
        }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            ICar seat  = new Seat("Leon", "Grey");
            ICar tesla = new Tesla("Model 3", "Red", 2);

            Console.WriteLine(seat.ToString());
            seat.Start();
            seat.Stop();
            Console.WriteLine(tesla.ToString());
            tesla.Start();
            tesla.Stop();
        }
Ejemplo n.º 12
0
        public static void Main(string[] args)
        {
            Seat  seat  = new Seat("Grey", "Leon");
            Tesla tesla = new Tesla("Red", "Model 3", 2);

            Console.WriteLine(seat);
            Console.WriteLine(seat.Start());
            Console.WriteLine(seat.Stop());

            Console.WriteLine(tesla);
            Console.WriteLine(tesla.Start());
            Console.WriteLine(tesla.Stop());
        }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            Seat seat = new Seat();

            System.Console.WriteLine(seat.Start());//From base class
            System.Console.WriteLine(seat.Stop());

            ICar tesla = new Tesla("3", "Black");

            System.Console.WriteLine(tesla.Start());
            System.Console.WriteLine(tesla.ToString());
            System.Console.WriteLine(tesla.Stop());
            System.Console.WriteLine(tesla.ToString());
        }
Ejemplo n.º 14
0
        public static void Main(string[] args)
        {
            try
            {
                ICar seat  = new Seat("Leon", "Grey");
                ICar tesla = new Tesla("Model 3", "Red", 2);

                Console.WriteLine(seat.ToString());
                Console.WriteLine(tesla.ToString());
            }
            catch (ArgumentException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            string tmp;
            Cars   cars = new Cars(3);

            cars[0] = new Lamborghini("Huracan EVO", 1422, 2, 80, 14, 270, 520);
            cars[1] = new Tesla("Model X", 2400, 5, 100, 2, 250, 770);
            cars[2] = new Ferrari("488 Pista", 1350, 2, 80, 12, 340, 720);

            int    car = 1;
            double x;

            while (car >= 1 && car <= 3)
            {
                Console.WriteLine("1 - Lamborghini\n" +
                                  "2 - Tesla\n" +
                                  "3 - Ferrari\n" +
                                  "0 - Exit");
                do
                {
                    Console.Write("Ваш выбор: ");
                    tmp = Console.ReadLine();
                } while (!int.TryParse(tmp, out car) || (car < 0) || (car > 3));
                int request = 1;
                switch (car)
                {
                case 1:
                    while (request > 0)
                    {
                        Console.WriteLine("1 - Информация про Lamborghini\n" +
                                          "2 - Погнали\n" +
                                          "3 - Заправить автомобиль\n" +
                                          "4 - Режим Strada\n" +
                                          "5 - Режим Sport\n" +
                                          "6 - Режим Corsa\n" +
                                          "0 - Выбрать другой автомобиль");
                        do
                        {
                            Console.Write("Ваш выбор : ");
                            tmp = Console.ReadLine();
                        } while (!int.TryParse(tmp, out request) || (request < 0));
                        switch (request)
                        {
                        case 1:
                            cars[car - 1].ShowInfo();
                            break;

                        case 2:
                            Console.Write("Введите расстояние в километрах:");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].Move(x);
                            break;

                        case 3:
                            Console.Write("Введите кол-во топлива : ");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].FillUpTank(x);
                            break;

                        case 4:
                            cars[car - 1].Strada();
                            break;

                        case 5:
                            cars[car - 1].Sport();
                            break;

                        case 6:
                            cars[car - 1].Corsa();
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                case 2:
                    while (request > 0)
                    {
                        Console.WriteLine("1 - Информация про Tesla\n" +
                                          "2 - Погнали\n" +
                                          "3 - Заправить автомобиль\n" +
                                          "0 - Выбрать другой автомобиль");
                        do
                        {
                            Console.Write("Ваш выбор : ");
                            tmp = Console.ReadLine();
                        } while (!int.TryParse(tmp, out request) || (request < 0));
                        switch (request)
                        {
                        case 1:
                            cars[car - 1].ShowInfo();
                            break;

                        case 2:
                            Console.Write("Введите расстояние в километрах:");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].Move(x);
                            break;

                        case 3:
                            Console.Write("Введите кол-во kW: ");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].FillUpTank(x);
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                case 3:
                    while (request > 0)
                    {
                        Console.WriteLine("1 - Информация про Ferrari\n" +
                                          "2 - Погнали\n" +
                                          "3 - Заправить автомобиль\n" +
                                          "4 - Включить drift mode (RWD)\n" +
                                          "5 - Выключить drift mode (4WD)\n" +
                                          "0 - Выбрать другой автомобиль");
                        do
                        {
                            Console.Write("Ваш выбор : ");
                            tmp = Console.ReadLine();
                        } while (!int.TryParse(tmp, out request) || (request < 0));
                        switch (request)
                        {
                        case 1:
                            cars[car - 1].ShowInfo();
                            break;

                        case 2:
                            Console.Write("Введите расстояние в километрах:");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].Move(x);
                            break;

                        case 3:
                            Console.Write("Введите кол-во топлива : ");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].FillUpTank(x);
                            break;

                        case 4:
                            cars[car - 1].DriftON();
                            break;

                        case 5:
                            cars[car - 1].DriftOFF();
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            Lamborgini lamba = new Lamborgini(" Aventador", 1550, 2300, 2, 80, 14, 270);
            Tesla      tesla = new Tesla(" Model X", 2400, 3300, 5, 100000, 1500, 250);
            McLaren    mac   = new McLaren(" 720s", 1350, 2100, 2, 80, 12, 340);

            List <Car> p = new List <Car>()
            {
                lamba, tesla, mac
            };

            Console.WriteLine("До сортировки:");
            foreach (Car i in p)
            {
                i.ShortInfo();
            }
            p.Sort();
            Console.WriteLine("Отсортировано по возрастанию скорости:");
            foreach (Car i in p)
            {
                i.ShortInfo();
            }

            string tmp;

            Cars cars = new Cars(3);

            cars[0] = new Lamborgini(" Aventador", 1550, 2300, 2, 80, 14, 270);
            cars[1] = new Tesla(" Model X", 2400, 3300, 5, 100000, 1500, 250);
            cars[2] = new McLaren(" 720s", 1350, 2100, 2, 80, 12, 340);

            int car = 0;

            while (car < 1 || car > 3)
            {
                Console.WriteLine("1 - Lamborghini\n" +
                                  "2 - Tesla\n" +
                                  "3 - McLaren\n");
                do
                {
                    Console.Write("Ваш выбор: ");
                    tmp = Console.ReadLine();
                } while (!int.TryParse(tmp, out car) || (car < 0) || (car > 3));
            }
            Console.Clear();
            int request = 1;

            while (request > 0)
            {
                Console.WriteLine("1 - Информация про автомобиль\n" +
                                  "2 - Проверить топливо(заряд)\n" +
                                  "3 - Поехали\n" +
                                  "4 - Слить топливо/ разрядить\n" +
                                  "5 - доЗаправить\n" +
                                  "6 - Заправить\n" +
                                  "0 - Выход");
                tmp = Console.ReadLine();
                int.TryParse(tmp, out request);
                Console.Clear();
                double x;
                switch (request)
                {
                case 1:
                    cars[car - 1].ShowInfo();
                    break;

                case 2:
                    if (car == 2)
                    {
                        Console.WriteLine("Батарея заряжена на {0} mA/h", cars[car - 1].CurrentFuelVolume);
                    }
                    else
                    {
                        Console.WriteLine("В баке {0} л. топлива", cars[car - 1].CurrentFuelVolume);
                    }
                    break;

                case 3:
                    Console.WriteLine("Введите расстояние в километрах ");
                    tmp = Console.ReadLine();
                    double.TryParse(tmp, out x);
                    cars[car - 1].Move(x);
                    if (car == 2)
                    {
                        Console.WriteLine("Батарея заряжена на {0} mA/h", cars[car - 1].CurrentFuelVolume);
                    }
                    else
                    {
                        Console.WriteLine("В баке {0} л. топлива", cars[car - 1].CurrentFuelVolume);
                    }
                    break;

                case 4:
                    tmp = Console.ReadLine();
                    double.TryParse(tmp, out x);
                    x = cars[car - 1].DrainFuel(x);
                    break;

                case 5:
                    cars[car - 1].FillUpTank();
                    break;

                case 6:
                    tmp = Console.ReadLine();
                    double.TryParse(tmp, out x);
                    cars[car - 1].FillUpTank(x);
                    break;

                default:
                    break;
                }
            }
        }
Ejemplo n.º 17
0
        static void Main(string[] args)
        {
            Car lamba = new Lamborghini("Aventador SVJ", 1575, 2, 80, 16, 300, 570);
            Car ferra = new Ferrari("F12 berlinetta", 1350, 2, 80, 12, 280, 720);
            Car tesla = new Tesla("Model X", 2400, 5, 100, 2, 250, 770);

            List <Car> arr = new List <Car>()
            {
                lamba, ferra, tesla
            };

            Console.WriteLine("Before sorting:");
            foreach (Car i in arr) //before Lamborghini Ferrari Tesla
            {
                i.ShortInfo();
            }
            arr.Sort();
            Console.WriteLine("After sorting:");
            foreach (Car i in arr) //after Tesla Ferrari Lamborghini
            {
                i.ShortInfo();
            }

            cars[0] = new Lamborghini("Huracan EVO", 1422, 2, 80, 14, 270, 520);
            cars[1] = new Tesla("Model X", 2400, 5, 100, 2, 250, 770);
            cars[2] = new Ferrari("488 Pista", 1350, 2, 80, 12, 340, 720);

            string tmp;
            int    car = 1;
            double x;

            while (car >= 1 && car <= 3)
            {
                Console.WriteLine("1 - Lamborghini\n" +
                                  "2 - Tesla\n" +
                                  "3 - Ferrari\n" +
                                  "0 - Exit");
                do
                {
                    Console.Write("Ваш выбор: ");
                    tmp = Console.ReadLine();
                } while (!int.TryParse(tmp, out car) || (car < 0) || (car > 3));
                int request = 1;
                switch (car)
                {
                case 1:
                    while (request > 0)
                    {
                        Console.WriteLine("1 - Информация про Lamborghini\n" +
                                          "2 - Погнали\n" +
                                          "3 - Заправить автомобиль\n" +
                                          "4 - Режим Strada\n" +
                                          "5 - Режим Sport\n" +
                                          "6 - Режим Corsa\n" +
                                          "0 - Выбрать другой автомобиль");
                        do
                        {
                            Console.Write("Ваш выбор : ");
                            tmp = Console.ReadLine();
                        } while (!int.TryParse(tmp, out request) || (request < 0));
                        switch (request)
                        {
                        case 1:
                            cars[0].Notify += message =>
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine(message);
                                Console.ResetColor();
                            };
                            cars[car - 1].ShowInfo();
                            break;

                        case 2:
                            Console.Write("Введите расстояние в километрах:");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].Move(x);
                            break;

                        case 3:
                            Console.Write("Введите кол-во топлива : ");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].FillUpTank(x);
                            break;

                        case 4:
                            cars[car - 1].Strada();
                            break;

                        case 5:
                            cars[car - 1].Sport();
                            break;

                        case 6:
                            cars[car - 1].Corsa();
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                case 2:
                    while (request > 0)
                    {
                        Console.WriteLine("1 - Информация про Tesla\n" +
                                          "2 - Погнали\n" +
                                          "3 - Заправить автомобиль\n" +
                                          "0 - Выбрать другой автомобиль");
                        do
                        {
                            Console.Write("Ваш выбор : ");
                            tmp = Console.ReadLine();
                        } while (!int.TryParse(tmp, out request) || (request < 0));
                        switch (request)
                        {
                        case 1:
                            cars[car - 1].ShowInfo();
                            break;

                        case 2:
                            Console.Write("Введите расстояние в километрах:");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].Move(x);
                            break;

                        case 3:
                            Console.Write("Введите кол-во kW: ");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].FillUpTank(x);
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                case 3:
                    while (request > 0)
                    {
                        Console.WriteLine("1 - Информация про Ferrari\n" +
                                          "2 - Погнали\n" +
                                          "3 - Заправить автомобиль\n" +
                                          "4 - Включить drift mode (RWD)\n" +
                                          "5 - Выключить drift mode (4WD)\n" +
                                          "0 - Выбрать другой автомобиль");
                        do
                        {
                            Console.Write("Ваш выбор : ");
                            tmp = Console.ReadLine();
                        } while (!int.TryParse(tmp, out request) || (request < 0));
                        switch (request)
                        {
                        case 1:
                            cars[car - 1].ShowInfo();
                            break;

                        case 2:
                            Console.Write("Введите расстояние в километрах:");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].Move(x);
                            break;

                        case 3:
                            Console.Write("Введите кол-во топлива : ");
                            tmp = Console.ReadLine();
                            double.TryParse(tmp, out x);
                            cars[car - 1].FillUpTank(x);
                            break;

                        case 4:
                            cars[car - 1].DriftON();
                            break;

                        case 5:
                            cars[car - 1].DriftOFF();
                            break;

                        default:
                            break;
                        }
                    }
                    break;

                default:
                    break;
                }
            }
            KeyHandler keyHandler = KeyInput;

            keyHandler += ChooseColor;
            RunInputLoop(keyHandler);
        }
Ejemplo n.º 18
0
        static void Main(string[] args)
        {
            //int Weight, MaxWeight;
            //int PassengerSeats;
            //int TankCapacity;
            //int TrunkVolume;
            //double FuelFlow;
            //int MaxSpeed;


            //do
            //{
            //    Console.WriteLine("Введите вес автомобиля : ");
            //    tmp = Console.ReadLine();
            //} while (!int.TryParse(tmp, out Weight));

            //do
            //{
            //    Console.WriteLine("Введите грузоподъемность автомобиля : ");
            //    tmp = Console.ReadLine();
            //} while (!int.TryParse(tmp, out MaxWeight));

            //MaxWeight += Weight;

            //do
            //{
            //    Console.WriteLine("Введите кол-во пассажирских мест в автомобиле : ");
            //    tmp = Console.ReadLine();
            //} while (!int.TryParse(tmp, out PassengerSeats));

            //do
            //{
            //    Console.WriteLine("Введите объем бака автомобиля : ");
            //    tmp = Console.ReadLine();
            //} while (!int.TryParse(tmp, out TankCapacity));

            //do
            //{
            //    Console.WriteLine("Введите расход топлива на 100 километров : ");
            //    tmp = Console.ReadLine();
            //} while (!double.TryParse(tmp, out FuelFlow));

            //do
            //{
            //    Console.WriteLine("Введите максимальную скорость автомобиля : ");
            //    tmp = Console.ReadLine();
            //} while (!int.TryParse(tmp, out MaxSpeed));
            string tmp;
            Cars   cars = new Cars(3);

            cars[0] = new Lamborgini(" Aventador", 1550, 2300, 2, 80, 14, 270);
            cars[1] = new Tesla(" Model X", 2400, 3300, 5, 100000, 1500, 250);
            cars[2] = new McLaren(" 720s", 1350, 2100, 2, 80, 12, 340);
            ArrayList CarList = new ArrayList
            {
                cars[0],
                cars[1],
                cars[2]
            };

            CarList.Sort();
            Console.WriteLine("Отсортировано по возрастанию скорости:");
            foreach (Car i in CarList)
            {
                Console.WriteLine(" " + i);
            }
            int car = 0;

            while (car < 1 || car > 3)
            {
                Console.WriteLine("1 - Lamborghini\n" +
                                  "2 - Tesla\n" +
                                  "3 - McLaren\n");
                do
                {
                    Console.Write("Ваш выбор: ");
                    tmp = Console.ReadLine();
                } while (!int.TryParse(tmp, out car) || (car < 0) || (car > 3));
            }
            Console.Clear();
            int request = 1;

            while (request > 0)
            {
                Console.WriteLine("1 - Информация про автомобиль\n" +
                                  "2 - Проверить топливо(заряд)\n" +
                                  "3 - Поехали\n" +
                                  "4 - Слить топливо/ разрядить\n" +
                                  "5 - доЗаправить\n" +
                                  "6 - Заправить\n" +
                                  "0 - Выход");
                tmp = Console.ReadLine();
                int.TryParse(tmp, out request);
                Console.Clear();
                double x;
                switch (request)
                {
                case 1:
                    cars[car - 1].ShowInfo();
                    break;

                case 2:
                    if (car == 2)
                    {
                        Console.WriteLine("Батарея заряжена на {0} mA/h", cars[car - 1].CurrentFuelVolume);
                    }
                    else
                    {
                        Console.WriteLine("В баке {0} л. топлива", cars[car - 1].CurrentFuelVolume);
                    }
                    break;

                case 3:
                    Console.WriteLine("Введите расстояние в километрах ");
                    tmp = Console.ReadLine();
                    double.TryParse(tmp, out x);
                    cars[car - 1].Move(x);
                    if (car == 2)
                    {
                        Console.WriteLine("Батарея заряжена на {0} mA/h", cars[car - 1].CurrentFuelVolume);
                    }
                    else
                    {
                        Console.WriteLine("В баке {0} л. топлива", cars[car - 1].CurrentFuelVolume);
                    }
                    break;

                case 4:
                    tmp = Console.ReadLine();
                    double.TryParse(tmp, out x);
                    x = cars[car - 1].DrainFuel(x);
                    break;

                case 5:
                    cars[car - 1].FillUpTank();
                    break;

                case 6:
                    tmp = Console.ReadLine();
                    double.TryParse(tmp, out x);
                    cars[car - 1].FillUpTank(x);
                    break;

                default:
                    break;
                }
            }
        }