コード例 #1
0
ファイル: AddVehicleMenu.cs プロジェクト: Dennis1111/Garage3
 private void AddAirPlane()
 {
     Console.Clear();
     if (GarageHandler.GarageIsFull())
     {
         Console.WriteLine("Garage is full come back later");
         return;
     }
     do
     {
         Console.WriteLine("Add an airplane");
         string  registrationNumber = Ui.AskForRegistrationNumber(GarageHandler);
         string  color          = Ui.AskForString("Enter a Color", minLength: 3, maxLength: 20);
         int     wheels         = Ui.AskForVehicleInt("Airplane", "wheels", min: 4, max: 20);
         string  manufacturer   = Ui.AskForString("Enter a manufactuer", minLength: 3, maxLength: 20);
         int     passengerSeats = Ui.AskForVehicleInt("Airplane", "passengerseats", min: 1, max: 6000);
         Vehicle vehicle        = new Airplane(registrationNumber, color, wheels, manufacturer, passengerSeats);
         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 airPlanes");
     } 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 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);
 }
コード例 #4
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);
        }
コード例 #5
0
ファイル: AddVehicleMenu.cs プロジェクト: Dennis1111/Garage3
        private void AddBus()
        {
            Console.Clear();
            if (GarageHandler.GarageIsFull())
            {
                Console.WriteLine("Garage is full come back later");
                return;
            }

            do
            {
                Console.WriteLine("Add a bus");
                string registrationNumber = Ui.AskForRegistrationNumber(GarageHandler);
                string color        = Ui.AskForString("Enter a Color", minLength: 3, maxLength: 20);
                int    wheels       = Ui.AskForVehicleInt("Bus", "wheels", min: 4, max: 100);
                string manufacturer = Ui.AskForString("Enter a manufactuer", minLength: 3, maxLength: 20);
                Console.WriteLine("Whats's the bus fueltype");
                string  fuelType = Console.ReadLine();
                Vehicle vehicle  = new Bus(registrationNumber, color, wheels, manufacturer, fuelType);
                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 another bus");
            } while (Console.ReadKey(intercept: true).Key == ConsoleKey.Y);
        }
コード例 #6
0
        private void SerchOnVechicleFeatures()
        {
            String regNum = "", color = "", manufacturer = "";
            int    wheels = 0;

            GarageHandler.StringPredicate regNumPredicate = null, colorPredicate = null, manufacturerPredicate = null;
            Console.Clear();
            Console.WriteLine("Find a vehicle by features");
            Console.WriteLine("To search on registration number press Y");

            if (Console.ReadKey(intercept: true).Key == ConsoleKey.Y)
            {
                regNum          = manufacturer = Ui.AskForString("Enter the registration number to search on", 5, 8);
                regNumPredicate = GetStringPredicate("Registration Number", regNum);
            }

            Console.WriteLine("To search on color press Y");
            if (Console.ReadKey(intercept: true).Key == ConsoleKey.Y)
            {
                Console.WriteLine("What Color do want to search on");
                color          = Console.ReadLine();
                colorPredicate = GetStringPredicate("Color", color);
            }

            Console.WriteLine("To search on wheels press Y");
            if (Console.ReadKey(intercept: true).Key == ConsoleKey.Y)
            {
                wheels = Ui.AskForInt("How many wheels should the vehicle have");
            }
            Console.WriteLine("To search on manufacturer press Y");

            if (Console.ReadKey(intercept: true).Key == ConsoleKey.Y)
            {
                Console.WriteLine("What manufacturer do want to search on");
                manufacturer          = Console.ReadLine();
                manufacturerPredicate = GetStringPredicate("Manufacturer", manufacturer);
            }

            var matchingVehicles = GarageHandler.GetVehicles(regNum, regNumPredicate, color, colorPredicate, wheels, manufacturer, manufacturerPredicate);

            Console.WriteLine($"Found {matchingVehicles.Count()} matching vehicles");
            foreach (var vehicle in matchingVehicles)
            {
                Console.WriteLine(vehicle);
            }
            Console.WriteLine("Press space to go back to main menu");
            do
            {
            } while (Console.ReadKey(intercept: true).KeyChar != ' ');
            this.Start();
        }
コード例 #7
0
        private void RemoveVehicle()
        {
            if (GarageHandler.GarageIsEmpty())
            {
                Console.WriteLine("Garage is empty come back later");
                return;
            }
            do
            {
                string regNr = Ui.AskForString("Enter the registrationnumber for vehicle you want to remove", 5, 8);

                if (GarageHandler.Contains(regNr))
                {
                    GarageHandler.RemoveVehicle(regNr);
                }
                else
                {
                    Console.WriteLine($"Couldn't find a vehicle with registrationnumber {regNr} to remove");
                }
                Console.WriteLine("Press Y if want to remove more cars");
            } while (Console.ReadKey(intercept: true).Key == ConsoleKey.Y);
        }