Exemplo n.º 1
0
 private void AddRandomVehicles(int notused)
 {
     MyGarage?.Add(new Vehicle()
     {
         RegNr = "ABC123", Brand = "Generic", Model = "Oddball", Color = "Pink", Wheels = 4
     });
     MyGarage?.Add(new Airplane()
     {
         RegNr = "XXX666", Brand = "Boing", Model = "747", Color = "White", Wheels = 12
     });
     MyGarage?.Add(new Motorcycle()
     {
         RegNr = "ZOO123", Brand = "Yamaha", Model = "CR80", Color = "Red", CylVolume = 80
     });
     MyGarage?.Add(new Boat()
     {
         RegNr = "TXT000", Brand = "Otter", Model = "T500", Color = "Orange", Wheels = 0, Length = 5
     });
     MyGarage?.Add(new Car()
     {
         RegNr = "ZOO567", Brand = "Volvo", Model = "V70", Color = "Silver", FuelType = "Gasoline"
     });
 }
Exemplo n.º 2
0
        public void VehicleInput()
        {
            //Vehicle vehicle = new Vehicle("VehicleType", 6,"An",9);



            Console.WriteLine("Choose the Vehcile type  ");
            Console.WriteLine("1) Park a Car ");
            Console.WriteLine("2) Park a Buss ");
            Console.WriteLine("3) Park an Airplan");
            Console.WriteLine("4) Park a Motorcycle ");
            Console.WriteLine("5) Park a Boat ");


            string VehicleType = Console.ReadLine();

            Console.WriteLine("Enter Your Vehicle Number ");
            string RegNumber = Console.ReadLine();


            Console.WriteLine("Enter The Color");
            string Color = Console.ReadLine();

            string NrOfWheels     = "";
            int    NrOfWeelsCheck = 0;

            do
            {
                Console.WriteLine("Enter Number of your Vehicle Wheels ");
                NrOfWheels     = Console.ReadLine();
                NrOfWeelsCheck = 0;
                if (int.TryParse(NrOfWheels, out NrOfWeelsCheck))
                {
                }
                else
                {
                    Console.WriteLine("Incorrect Input");
                }
            } while (int.TryParse(NrOfWheels, out NrOfWeelsCheck) == false);
            Vehicle vehicle = null;

            switch (VehicleType)
            {
            case "1":
                Console.WriteLine("choose the fuel type");
                string FuelType = Console.ReadLine();
                vehicle = new Car(RegNumber, VehicleType, Color, NrOfWeelsCheck, FuelType);
                break;

            case "2":
                Console.WriteLine("choose the Number of Seats");
                string NumberOfSeats = Console.ReadLine();
                vehicle = new Car(RegNumber, VehicleType, Color, NrOfWeelsCheck, NumberOfSeats);
                break;

            case "3":
                Console.WriteLine("choose the Number of Engines");
                string NumberOfEngines = Console.ReadLine();
                vehicle = new Car(RegNumber, VehicleType, Color, NrOfWeelsCheck, NumberOfEngines);
                break;

            case "4":
                Console.WriteLine("How much Cylinder Volume");
                string CylinderVolume = Console.ReadLine();
                vehicle = new Car(RegNumber, VehicleType, Color, NrOfWeelsCheck, CylinderVolume);
                break;

            case "5":
                Console.WriteLine("choose the Boat Length");
                string Length = Console.ReadLine();
                vehicle = new Car(RegNumber, VehicleType, Color, NrOfWeelsCheck, Length);
                break;



            default:
                break;
            }

            garage.Add(vehicle);
        }