Exemple #1
0
        public Garage <T> CreateAGarage(string name, string address, int capacity)
        {
            Garage <T> garage = new Garage <T>(name, address, capacity);

            return(garage);
        }
Exemple #2
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();
        }
Exemple #3
0
 public int GetCapacity(Garage <T> garage)
 {
     return(garage.Capacity);
 }
Exemple #4
0
 public int GetCount(Garage <T> garage)
 {
     return(garage.Count);
 }
Exemple #5
0
 public string GetAddress(Garage <T> garage)
 {
     return(garage.Address);
 }
Exemple #6
0
 public void SetCapacity(Garage <T> garage, int capacity)
 {
     garage.Capacity = capacity;
 }
Exemple #7
0
 public string TypeVehicle(Garage <Vehicle> garage)
 {
     return(garage.ListType());
 }
Exemple #8
0
 public void SetAddress(Garage <T> garage, string address)
 {
     garage.Address = address;
 }
Exemple #9
0
 public string GetName(Garage <T> garage)
 {
     return(garage.Name);
 }
Exemple #10
0
 public string ShowVehicleList(Garage <Vehicle> garage)
 {
     return(garage.List());
 }
Exemple #11
0
 public void SetName(Garage <T> garage, string name)
 {
     garage.Name = name;
 }