コード例 #1
0
ファイル: AddVehicleMenu.cs プロジェクト: Dennis1111/Garage3
 private void AddCar()
 {
     Console.Clear();
     if (GarageHandler.GarageIsFull())
     {
         Console.WriteLine("Garage is full come back later");
         return;
     }
     do
     {
         Console.WriteLine("Add a car");
         string  registrationNumber = Ui.AskForRegistrationNumber(GarageHandler);
         string  color        = Ui.AskForString("Enter a Color", minLength: 3, maxLength: 20);
         int     wheels       = Ui.AskForVehicleInt("Car", "Wheels", min: 3, max: 4);
         string  manufacturer = Ui.AskForString("Enter a manufactuer", minLength: 3, maxLength: 20);
         bool    autonomous   = Ui.AskForBool("Is the car autonomous");
         Vehicle vehicle      = new Car(registrationNumber, color, wheels, manufacturer, autonomous);
         bool    added        = GarageHandler.AddVehicle(vehicle);
         Console.WriteLine($"You added the Vehicle\n {vehicle}\nto the Garage");
         if (GarageHandler.GarageIsFull())
         {
             Console.WriteLine("Garage is now full");
             break;
         }
         Console.WriteLine("Press Y if want to Add more cars");
     } while (Console.ReadKey(intercept: true).Key == ConsoleKey.Y);
 }
コード例 #2
0
ファイル: AddVehicleMenu.cs プロジェクト: Dennis1111/Garage3
        private void AddBoat()
        {
            Console.Clear();
            if (GarageHandler.GarageIsFull())
            {
                Console.WriteLine("Garage is full come back later");
                return;
            }
            do
            {
                Console.WriteLine("Add a boat");
                string registrationNumber = Ui.AskForRegistrationNumber(GarageHandler);

                string color        = Ui.AskForString("Enter a Color", minLength: 3, maxLength: 20);
                string manufacturer = Ui.AskForString("Enter a manufactuer", minLength: 3, maxLength: 20);

                bool    cargoShip = Ui.AskForBool("Is it a cargo ship");
                Vehicle vehicle   = new Boat(registrationNumber, color, manufacturer, cargoShip);
                GarageHandler.AddVehicle(vehicle);
                Console.WriteLine($"You added the Vehicle {vehicle} to the Garage");
                if (GarageHandler.GarageIsFull())
                {
                    break;
                }
                Console.WriteLine("Press Y if want to Add more boats");
            } while (Console.ReadKey(intercept: true).Key == ConsoleKey.Y);
        }
コード例 #3
0
ファイル: AddVehicleMenu.cs プロジェクト: Dennis1111/Garage3
        private void AddMotorCycle()
        {
            Console.Clear();
            if (GarageHandler.GarageIsFull())
            {
                Console.WriteLine("Garage is full come back later");
                return;
            }

            do
            {
                Console.WriteLine("Add a motorcycle");
                string  registrationNumber = Ui.AskForRegistrationNumber(GarageHandler);
                string  color        = Ui.AskForString("Enter a Color", minLength: 3, maxLength: 20);
                int     wheels       = Ui.AskForVehicleInt("motorcycle", "wheels", min: 2, max: 3);
                string  manufacturer = Ui.AskForString("Enter a manufactuer", minLength: 3, maxLength: 20);
                bool    sidecar      = Ui.AskForBool("Has the motorcycle a sidecar");
                Vehicle vehicle      = new MotorCycle(registrationNumber, color, wheels, manufacturer, sidecar);
                GarageHandler.AddVehicle(vehicle);
                Console.WriteLine($"You added the Vehicle {vehicle} to the Garage");
                if (GarageHandler.GarageIsFull())
                {
                    break;
                }
                Console.WriteLine("Press Y if want to Add more motorCycles");
            } while (Console.ReadKey(intercept: true).Key == ConsoleKey.Y);
        }