Ejemplo n.º 1
0
    static void Main()
    {
        ConsoleKeyInfo ch;
        Vehicle choosen_car = new Vehicle("", "", 0, "", false);
        Vehicle car1 = new Vehicle("Peugeot", "Green", 120, "France", false);
        Vehicle car2 = new Vehicle("Opel", "Black", 150, "Germany", false);

        while (true)
        {
            Console.Clear();
            Console.WriteLine("Vehicle type:");
            Console.WriteLine(Vehicle.VehicleType);
            Console.WriteLine("");
            car1.Information();
            car2.Information();
            Console.WriteLine("");
            Console.WriteLine("1 - Start the car");
            Console.WriteLine("2 - Choose the car");
            Console.WriteLine("3 - Fuel the car");
            Console.WriteLine("0 - Exit");
            ch = Console.ReadKey();
            if (ch.KeyChar == '1')
            {
                Console.Clear();
                if (choosen_car.CarBrand == "")
                    choosen_car.StartTheCar();
                else
                    choosen_car.StartTheCar(choosen_car);
            }
            if (ch.KeyChar == '2')
            {
                Console.Clear();
                Console.WriteLine("What car do you want to choose?");
                Console.WriteLine("1 - Peugeot");
                Console.WriteLine("2 - Opel");
                ch = Console.ReadKey();
                if (ch.KeyChar == '1')
                    choosen_car = car1;
                if (ch.KeyChar == '2')
                    choosen_car = car2;
            }
            if (ch.KeyChar == '3')
            {
                Console.Clear();
                Console.WriteLine("What car do you want to fill?");
                Console.WriteLine("1 - Peugeot");
                Console.WriteLine("2 - Opel");
                ch = Console.ReadKey();
                if (ch.KeyChar == '1')
                    car1.FuelTheCar(car1);
                if (ch.KeyChar == '2')
                    car2.FuelTheCar(car2);
            }
            if (ch.KeyChar == '0')
                break;
            Console.ReadKey();
        }
    }