Example #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("\t\t\t==== Wellcome ====");
            Garage mycars = new Garage();

            mycars.AddCar("Chevrolet", "Silverado");
            mycars.AddCar("Audi", "Q7");
            mycars.AddCar("Ford", "Fusion");
            Console.WriteLine(mycars.MyCars.Count.ToString());
            bool run = true;

            Header();
            do
            {
                var key = Console.ReadKey();
                switch (key.KeyChar)
                {
                case (char)ConsoleKey.D1:     //Print Cars
                    Console.WriteLine("press 0 to quit");
                    mycars.PrintCars();
                    break;

                case (char)ConsoleKey.D2:     //Select car
                    Console.WriteLine("Please Type ID (NUMBERS) only and Press Enter : ");
                    int selector = Convert.ToInt32(Console.ReadLine());
                    if (selector > mycars.MyCars.Count)
                    {
                        Console.WriteLine("We don't have a car with this ID number");
                    }
                    else
                    {
                        Test_Drive(mycars.SelectCar(selector));
                    }
                    break;

                case (char)ConsoleKey.D3:     //Add car
                    Console.Write(" Make : ");
                    string make = Console.ReadLine();
                    Console.Write(" Model : ");
                    string model = Console.ReadLine();
                    mycars.AddCar(make, model);
                    Console.WriteLine("Car {0} {1} is parked in garage", make, model);

                    break;

                case (char)ConsoleKey.D4:     //Remove Car
                    Console.WriteLine("Please Type ID   and Press Enter  to remove car from list ");
                    int index = Convert.ToInt32(Console.ReadLine());

                    mycars.RemoveCar(index);
                    Console.WriteLine("Press 1 to Print list");
                    break;

                case (char)ConsoleKey.D5:     //Fuell All Cars
                    Console.WriteLine("You fueled all cars!");
                    mycars.FuelAllCars();
                    Console.WriteLine("press 0 to quit");
                    break;

                case (char)ConsoleKey.D0:     //Select car
                    run = false;
                    break;

                default:
                    Console.WriteLine("\n\npress 0 to quit");
                    break;
                }
            }while (run);
        }