Esempio n. 1
0
        private static void ParkVehicleToGarage(GarageHandler garagehandler)
        {
            string Vehicletype = Util.AskForString("Please Specify which Vehicle to be Parked" +
                                                   "\nAirplane" +
                                                   "\nMotorCycle" +
                                                   "\nCar" +
                                                   "\nBus" +
                                                   "\nBoat");

            if (Enum.IsDefined(typeof(vehicletypes), Vehicletype))
            {
                string regNo      = Util.AskForString("Reg No of the Vehicle");
                string color      = Util.AskForString("Color of the Vehicle");
                int    noofwheels = Util.AskForInt("number of wheels");

                switch (Vehicletype.ToLower())
                {
                case "airplane":

                    int noofengines = Util.AskForInt("number of Engines of airplane");
                    var airplane    = new Airplane(regNo, color, noofwheels, noofengines);
                    garagehandler.ParkVehicle(airplane);

                    break;

                case "motorcycle":

                    int cylindervolume = Util.AskForInt("CylinderVolume of motorcycle");
                    var motorcycle     = new Motorcycle(regNo, color, noofwheels, cylindervolume);
                    garagehandler.ParkVehicle(motorcycle);
                    break;

                case "car":

                    string fueltype = Util.AskForString("FuelType of car");
                    var    car      = new Car(regNo, color, noofwheels, fueltype);
                    garagehandler.ParkVehicle(car);
                    break;

                case "bus":

                    int noofseats = Util.AskForInt("No of Seats in bus");
                    var bus       = new Bus(regNo, color, noofwheels, noofseats);
                    garagehandler.ParkVehicle(bus);
                    break;

                case "boat":

                    int length = Util.AskForInt("Length of boat");
                    var boat   = new Boat(regNo, color, noofwheels, length);
                    garagehandler.ParkVehicle(boat);
                    break;


                default:
                    break;
                }
            }
            else
            {
                Console.WriteLine($"you have enter value:{Vehicletype}. please enter valid input");
                Console.WriteLine();
            }
        }
Esempio n. 2
0
        private static void ParkVehicleToGarage(GarageHandler garagehandler)
        {
            Console.WriteLine("Please Specify which Vehicle to be Parked" +
                              "\nAirplane" +
                              "\nMotorCycle" +
                              "\nCar" +
                              "\nBus" +
                              "\nBoat");
            string Vehicletype = Console.ReadLine();

            Console.WriteLine("Please specify Reg No of the Vehicle");
            string regNo = Console.ReadLine();

            Console.WriteLine("Please specify Color of the Vehicle");
            string color = Console.ReadLine();

            Console.WriteLine("Please specify number of wheels");
            string noofwheels = Console.ReadLine();

            switch (Vehicletype.ToLower())
            {
            case "airplane":
                Console.WriteLine("Please specify number of Engines");
                string noofengines = Console.ReadLine();
                var    airplane    = new Airplane(regNo, color, int.Parse(noofwheels), int.Parse(noofengines));
                garagehandler.ParkVehicle(airplane);

                break;

            case "motorcycle":
                Console.WriteLine("Please specify CylinderVolume");
                string cylindervolume = Console.ReadLine();
                var    motorcycle     = new Motorcycle(regNo, color, int.Parse(noofwheels), int.Parse(cylindervolume));
                garagehandler.ParkVehicle(motorcycle);
                break;

            case "car":
                Console.WriteLine("Please specify FuelType");
                string fueltype = Console.ReadLine();
                var    car      = new Car(regNo, color, int.Parse(noofwheels), fueltype);
                garagehandler.ParkVehicle(car);
                break;

            case "bus":
                Console.WriteLine("Please specify No of Seats");
                string noofseats = Console.ReadLine();
                var    bus       = new Bus(regNo, color, int.Parse(noofwheels), int.Parse(noofseats));
                garagehandler.ParkVehicle(bus);
                break;

            case "boat":
                Console.WriteLine("Please specify Length");
                string length = Console.ReadLine();
                var    boat   = new Boat(regNo, color, int.Parse(noofwheels), int.Parse(length));
                garagehandler.ParkVehicle(boat);
                break;


            default:
                break;
            }
        }