Example #1
0
        private static void UnparkVehicle(Garage <Vehicle> garage)
        {
            Console.Clear();
            List <string> parkedvehiclesList = new List <string>();

            Console.WriteLine("                       PARKED VEHICLES:");
            Console.WriteLine("----------------------------------------------------------------------");
            Console.WriteLine("Please first find your vehicle to unpark it... ");
            Console.Write("What is the registration number of your vehicle? ");
            string userunpark = Console.ReadLine();
            GarageHandler <Vehicle> unpark = new GarageHandler <Vehicle>();

            Console.WriteLine(unpark.UnParkVehicle(garage, userunpark, 0));
            Console.WriteLine("\n--------------Unparked vehicle---------------");
            Console.WriteLine(unpark.ShowVehicleList(garage));
            Console.ReadLine();
        }
Example #2
0
        private static void DisplayVehicleList(Garage <Vehicle> garage, int choice)
        {
            GarageHandler <Vehicle> handler = new GarageHandler <Vehicle>();

            Console.Clear();

            if (choice == 1)
            {
                Console.WriteLine("LIST OF ALL THE VEHICLES  PARKED IN THE GARAGE");
                Console.WriteLine("----------------------------------------------------------------------");
                Console.WriteLine(handler.ShowVehicleList(garage));
            }
            if (choice == 2)
            {
                Console.WriteLine("LIST OF VEHICLE TYPES");
                Console.WriteLine("----------------------------------------------------------------------");
                Console.WriteLine(handler.ShowVehicleListType(garage));
            }
        }
Example #3
0
        private static void ParkVehicle(Garage <Vehicle> garage)
        {
            Console.Clear();
            GarageHandler <Vehicle> handler = new GarageHandler <Vehicle>();

            Console.WriteLine("                       PARKERING YOUR VEHICLE");
            Console.WriteLine("----------------------------------------------------------------------");
            Console.WriteLine("What type of vehicle you want to park? \nPlease, choosing one of the following options:" +
                              "\n1) AIRPLANE" + "\n2) BOAT" + "\n3) BUS" + "\n4) CAR" + "\n5) MOTORCYCLE");
            string userinput = Console.ReadLine();

            Console.WriteLine("Please answer the next questions...\n");
            Console.Write("What is the registration number of your vehicle? ");
            string regNr = Console.ReadLine();

            Console.Write("What is the color of the vehicle? ");
            string color          = Console.ReadLine();
            string numberOfWheels = Console.ReadLine();
            int    number;

            Console.WriteLine("How many wheels does your vehicle have? ");
            while (!int.TryParse(Console.ReadLine(), out number))
            {
                Console.Write("Invalid number! Please try again. ");
            }


            while (!int.TryParse(Console.ReadLine(), out number))
            {
                Console.Write("Invalid number! Please try again. ");
            }
            if (userinput == "1")
            {
                userinput = "Airplane";
                string numof = Console.ReadLine();
                Console.WriteLine("How many engines does your airplane have? ");
                while (!int.TryParse(Console.ReadLine(), out number))
                {
                    Console.Write("Invalid number! Please try again. ");
                }
                Airplane a = new Airplane(regNr, color, number, number);
                handler.ParkVehicle(garage, a, 0);
            }
            else if (userinput == "2")
            {
                userinput = "Boat";
                Console.WriteLine("What is the length of your boat? ");
                while (!int.TryParse(Console.ReadLine(), out number))
                {
                    Console.WriteLine("Invalid number! Please try again. ");
                }
                Boat a = new Boat(regNr, color, number, number);
                handler.ParkVehicle(garage, a, 0);
            }
            else if (userinput == "3")
            {
                userinput = "Car";
                Console.WriteLine("Which fuel type does your car have? ");
                string fuel = Console.ReadLine();
                Car    a    = new Car(regNr, color, number, fuel);
                handler.ParkVehicle(garage, a, 0);
            }
            else if (userinput == "4")
            {
                userinput = "Motorcycle";
                Console.WriteLine("How much cylinder volume does your motorcycle have? ");
                while (!int.TryParse(Console.ReadLine(), out number))
                {
                    Console.WriteLine("Invalid input! Please try again. ");
                }
                Motorcycle a = new Motorcycle(regNr, color, number, number);
                handler.ParkVehicle(garage, a, 0);
            }
            Console.WriteLine("\n--------------Parked vehicle---------------");
            Console.WriteLine(handler.ShowVehicleList(garage));
            Console.ReadLine();
        }