示例#1
0
        public static string test(Garage <Vehicle> garage, int c)
        {
            Car car = new Car();

            car.RegNr       = "123abc";
            car.Colour      = "Blue";
            car.NbrOFSeats  = 5;
            car.FuelType    = "Gasole";
            car.TypOfEngine = "V8";
            car.TypOfModel  = "Combie";
            car.Brand       = "BMW";
            car.WheelDrive  = "Front";

            Airplane aplane = new Airplane();

            aplane.RegNr       = "456def";
            aplane.Colour      = "White";
            aplane.NbrOFSeats  = 65;
            aplane.FuelType    = "Infants";
            aplane.TypOfEngine = "Jet";
            aplane.TypOfModel  = "Private";
            aplane.WingSpan    = 50;

            Tank tank = new Tank();

            tank.RegNr       = "789ghi";
            tank.Colour      = "Olive";
            tank.NbrOFSeats  = 3;
            tank.FuelType    = "Disel";
            tank.TypOfEngine = "Tractor";
            tank.TypOfModel  = "Scout";
            tank.Caliber     = 50;

            garage.AddToArray(car);
            garage.AddToArray(aplane);
            garage.AddToArray(tank);

            return(car.Stats() + aplane.Stats() + tank.Stats());
        }
示例#2
0
        public static string AddAirplane(Garage <Vehicle> garage)
        {
            Airplane aplane = new Airplane();

            Console.WriteLine("What is the Registration Number of the Airplane?");
            Console.Write("> ");
            aplane.RegNr = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What Colour is the airplane?");
            Console.Write("> ");
            aplane.Colour = Console.ReadLine();

            aplane.NbrOFSeats = EnvisInmat();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What fuel does the airplane use?");
            Console.Write("> ");
            aplane.FuelType = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What engine does the airplane have?");
            Console.Write("> ");
            aplane.TypOfEngine = Console.ReadLine();

            Console.Clear();
            Scene.title();
            Console.WriteLine("What model is the airplane?");
            Console.Write("> ");
            aplane.TypOfModel = Console.ReadLine();

            bool y = true;

            while (y)
            {
                try
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("What is the wingspan?");
                    Console.Write("> ");
                    aplane.WingSpan = int.Parse(Console.ReadLine());
                    y = false;
                }
                catch
                {
                    Console.Clear();
                    Scene.title();
                    Console.WriteLine("Please enter a number");
                    Console.ReadKey();
                    y = true;
                }
            }

            Console.Clear();
            Scene.title();
            Console.WriteLine(aplane.Stats());
            Console.ReadKey();

            garage.AddToArray(aplane);

            return(aplane.Stats());
        }
示例#3
0
文件: UI.cs 项目: paperfon/Garage-1.0
        private static void CreateAndParkVehicleMenu(Garage <Vehicle> garage)
        {
            // Todo: check first if the garage is full??
            var input = Utils.AskForNumber("Which vehicle do you want to park?"
                                           + "\n1. Airplane"
                                           + "\n2. Boat"
                                           + "\n3. Bus"
                                           + "\n4. Car"
                                           + "\n5. Motorcycle"
                                           + "\n0. Go back to the garage menu"
                                           + "\n - - - - - - - - - - - - - - ");

            var promptRegNumber        = "Registration number:";
            var promptFabricant        = "Brand:";
            var promptNumberOfWheels   = "Number of wheels:";
            var promptColor            = "Color:";
            var promptYearOfProduction = "Year of production:";

            switch (input)
            {
            case 1:
                var airplane = new Airplane(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    numberofengines: Utils.AskForNumber("Number of engines:")
                    );
                handler.ParkVehicle(garage, airplane);
                CreateAndParkVehicleMenu(garage);
                break;

            case 2:
                var boat = new Boat(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    length: Utils.AskForNumber("Length:")
                    );
                handler.ParkVehicle(garage, boat);
                CreateAndParkVehicleMenu(garage);
                break;

            case 3:
                var bus = new Bus(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    numberofseats: Utils.AskForNumber("Number of seats:")
                    );
                handler.ParkVehicle(garage, bus);
                CreateAndParkVehicleMenu(garage);
                break;

            case 4:
                var car = new Car(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    fueltype: Utils.AskForInput("Fuel type:")
                    );
                handler.ParkVehicle(garage, car);
                CreateAndParkVehicleMenu(garage);
                break;

            case 5:
                var motorcycle = new Motorcycle(
                    regnumber: Utils.AskForInput(promptRegNumber),
                    fabricant: Utils.AskForInput(promptFabricant),
                    numberofwheels: Utils.AskForNumber(promptNumberOfWheels),
                    color: Utils.AskForInput(promptColor),
                    productionyear: Utils.AskForNumber(promptYearOfProduction),
                    cylindervolume: Utils.AskForNumber("Cylinder volume:")
                    );
                handler.ParkVehicle(garage, motorcycle);
                CreateAndParkVehicleMenu(garage);
                break;

            case 0:
                GarageMenu(garage);
                break;

            default:
                Console.WriteLine("Please make a valid selection!\n");
                CreateAndParkVehicleMenu(garage);
                break;
            }
        }