Example #1
0
        private void AddCar()
        {
            var vehicle = AddVehicle();

            fuelType = ui.AskForString("Car's fuelType: ");
            var car = new Car(vehicle.RegNo, vehicle.Color, vehicle.NumOfWheels, fuelType);

            garageHandler.garage.Add(car);
        }
        private void FindVehicleByRegNr()
        {
            bool regNrExist = false;

            do
            {
                string regNr = ui.AskForString("Please enter the registration number of the vehicle!");
                try
                {
                    var vehicleToFind = handler.FindVehicleByRegNr(regNr);
                    if (regNr.Equals(regNr, StringComparison.InvariantCultureIgnoreCase))
                    {
                        Console.Clear();
                        ui.Print($"The vehicle yo searched for is a {vehicleToFind.Color} {vehicleToFind.GetType().Name}, that has {vehicleToFind.NrOfWheels} wheels ");
                        regNrExist = true;
                    }
                }
                catch (NullReferenceException)
                {
                    int input1 = ui.AskForInteger($"There is no vehicle in the garage that has this registration number: \u0022{regNr}\u0022. Please try again." +
                                                  $"\n Press 1 to try again" +
                                                  "\n press 2 to go back");

                    switch (input1)
                    {
                    case 1:
                        regNrExist = false;
                        break;

                    case 2:
                        regNrExist = true;
                        Console.Clear();
                        break;
                    }
                }
            } while (!regNrExist);
        }