Example #1
0
 private void changeVehicleStatus()
 {
     if (!isGarageEmpty())
     {
         try
         {
             Console.Clear();
             Console.WriteLine("choose one of the License numbers below: ");
             printAllVehicleLicense();
             string o_LicenseNumber = enterLicenseNumber();
             o_LicenseNumber = loopUntilLicenseIsFound(o_LicenseNumber);
             Console.Clear();
             Console.WriteLine("Enter 1 to change to 'in repair', 2 to change to 'repaired' or 3 to change to 'paid'");
             Vehicle.eVehicleStatus o_VehicleStatus = validateUserChoiceForVehicleStatus();
             r_GarageLogic.ChangeVehicleStatusInGarage(o_LicenseNumber, o_VehicleStatus);
             Console.WriteLine("Status of Vehicle {0} was changed To {1}\n", o_LicenseNumber, o_VehicleStatus);
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
             Console.WriteLine();
         }
     }
     else
     {
         Console.WriteLine("There are no vehicles yet in the system\n");
     }
 }
Example #2
0
        private void chooseStatusToPrint()
        {
            Console.WriteLine(@"Choose the status of the vehicles to present by the following numbers:
for vehicles that are in repair     press 1
for vehicles that are repaired      press 2
for vehicles that are paid for      press 3");

            Vehicle.eVehicleStatus userChoice = (Vehicle.eVehicleStatus)choiceValidation(1, 3);
            switch (userChoice)
            {
            case Vehicle.eVehicleStatus.InRepair:
            {
                printLicenseNumberByStatus(Vehicle.eVehicleStatus.InRepair);
                break;
            }

            case Vehicle.eVehicleStatus.Repaired:
            {
                printLicenseNumberByStatus(Vehicle.eVehicleStatus.Repaired);
                break;
            }

            case Vehicle.eVehicleStatus.Paid:
            {
                printLicenseNumberByStatus(Vehicle.eVehicleStatus.Paid);
                break;
            }
            }
        }
Example #3
0
        public void ChangeVehicleState(string i_LicenseNumber, Vehicle.eVehicleStatus i_NewStatus)
        {
            bool vehicleExists = r_AllVehicles.TryGetValue(i_LicenseNumber, out Vehicle requestedVehicle);

            if (vehicleExists)
            {
                requestedVehicle.VehicleStatus = i_NewStatus;
            }
            else
            {
                throw new ArgumentException("The license number entered is not in the system.");
            }
        }
Example #4
0
        public void ChangeVehicleStatus(string i_LicenseNumber, Vehicle.eVehicleStatus i_Status)
        {
            Vehicle vehicle;
            bool    isInGarage = GetVehicle(i_LicenseNumber, out vehicle);

            if (!isInGarage)
            {
                throw new System.ArgumentException(k_VehicleDoesntExist);
            }

            vehicle.VehicleStatus           = i_Status;
            GarageVehicles[i_LicenseNumber] = vehicle;
        }
Example #5
0
        public void ChangeVehicleStatusInGarage(string i_LicenseNumber, Vehicle.eVehicleStatus i_NewVehicleStatus)
        {
            IsGarageEmpty();

            if ((r_Vehicles.ContainsKey(i_LicenseNumber)) == true)
            {
                (r_Vehicles[i_LicenseNumber].VehicleStatus) = i_NewVehicleStatus;
            }
            else
            {
                throw new Exception("We don't have this vehicle in our garage, sorry.");
            }
        }
Example #6
0
        public List <string> CreateLicenseNumbersListByState(Vehicle.eVehicleStatus i_SortState)
        {
            List <string> vehiclesCurrentlyInGarageLicenseNumber = new List <string>();

            foreach (KeyValuePair <string, Vehicle> vehicle in r_AllVehicles)
            {
                if (i_SortState.Equals(vehicle.Value.VehicleStatus))
                {
                    vehiclesCurrentlyInGarageLicenseNumber.Add(vehicle.Value.LicenseNumber);
                }
            }

            return(vehiclesCurrentlyInGarageLicenseNumber);
        }
Example #7
0
        private Dictionary <string, Vehicle> filteredVehiclesByStatus(Vehicle.eVehicleStatus i_VehicleStatus)
        {
            Dictionary <string, Vehicle> filteredVehicles = new Dictionary <string, Vehicle>();

            foreach (Vehicle vehicle in m_GarageVehicles.Values)
            {
                if (vehicle.VehicleStatus == i_VehicleStatus)
                {
                    filteredVehicles.Add(vehicle.LicenseNumber, vehicle);
                }
            }

            return(filteredVehicles);
        }
Example #8
0
        private void changeVehicleState(string i_LicenseNumber)
        {
            bool successfulChange = false;

            do
            {
                try
                {
                    while (!r_CurrentGarage.AllVehicles.ContainsKey(i_LicenseNumber))
                    {
                        Console.WriteLine(@"This vehicle is not in the garage, please enter a valid License Number:
Please chose license number form list");
                        showVehiclesCurrentlyInTheGarage();
                        i_LicenseNumber = getLicenseNumber();
                    }

                    string vehicleStates = string.Format(
                        @"Please select state
In repair press 1
Repaired  press 2
Paid      press 3");

                    Console.WriteLine(vehicleStates);

                    string vehicleStateString = Console.ReadLine();
                    int.TryParse(vehicleStateString, out int vehicleState);

                    while (vehicleStateString == null || !Enum.IsDefined(typeof(Vehicle.eVehicleStatus), vehicleState))
                    {
                        Console.WriteLine(@"Please enter a valid state");
                        vehicleStateString = Console.ReadLine();
                        int.TryParse(vehicleStateString, out vehicleState);
                    }

                    Vehicle.eVehicleStatus vehicleStatus = (Vehicle.eVehicleStatus)Enum.Parse(
                        typeof(Vehicle.eVehicleStatus),
                        vehicleStateString);
                    r_CurrentGarage.ChangeVehicleState(i_LicenseNumber, vehicleStatus);
                    successfulChange = true;
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception.Message);
                }
            }while(!successfulChange);
        }
Example #9
0
        private void printLicenseNumberByStatus(Vehicle.eVehicleStatus i_StatusToShow)
        {
            int numberOfVehicles = 0;

            foreach (KeyValuePair <string, Vehicle> vehicle in r_GarageLogic.ListOfVehicles)
            {
                if (vehicle.Value.VehicleStatus == i_StatusToShow)
                {
                    Console.WriteLine(vehicle.Key);
                    numberOfVehicles++;
                }
            }

            if (numberOfVehicles == 0)
            {
                Console.WriteLine("No {0} vehicles to Show", i_StatusToShow);
            }
        }
Example #10
0
        private void showVehiclesCurrentlyInTheGarage()
        {
            List <string> licenseNumbersToPrint;

            Console.WriteLine(
                @"Please select the vehicles status:
In repair press 1
Repaired press 2
Paid press 3
All vehicles press 4");
            string vehicleStatusToPrint = Console.ReadLine();

            if (vehicleStatusToPrint != null && r_CurrentGarage.CheckIfVehicleStatusStringValid(vehicleStatusToPrint))
            {
                Vehicle.eVehicleStatus statusToPrint = (Vehicle.eVehicleStatus)Enum.Parse(
                    typeof(Vehicle.eVehicleStatus),
                    vehicleStatusToPrint);
                licenseNumbersToPrint = r_CurrentGarage.CreateLicenseNumbersListByState(statusToPrint);
            }
            else if (vehicleStatusToPrint == "4")
            {
                licenseNumbersToPrint = r_CurrentGarage.AllVehicles.Keys.ToList();
            }
            else
            {
                throw new ArgumentException(@"Invalid status entered");
            }

            foreach (string licenseNumber in licenseNumbersToPrint)
            {
                Console.WriteLine(licenseNumber);
            }

            Console.WriteLine(@"Press any key to continue");
            Console.ReadLine();
        }
Example #11
0
        public void ChangeVehicleStatus(string i_licenseNumber, Vehicle.eVehicleStatus i_newStatus)
        {
            Vehicle vehicle = getVehicle(i_licenseNumber);

            vehicle.m_vehicleStatus = i_newStatus;
        }
Example #12
0
 private Vehicle.eVehicleStatus validateUserChoiceForVehicleStatus()
 {
     Vehicle.eVehicleStatus o_UserChoice = (Vehicle.eVehicleStatus)choiceValidation(1, 3);
     return(o_UserChoice);
 }
Example #13
0
 public Dictionary <string, Vehicle> .KeyCollection GetFilteredListOfLicenseNumbers(Vehicle.eVehicleStatus i_VehicleStatus)
 {
     return(filteredVehiclesByStatus(i_VehicleStatus).Keys);
 }