Пример #1
0
        public string ShowListOfLicenseNumbersAccordingToStatus(Customer.eVehicleStatusInTheGarage i_VehicleStatus = 0)
        {
            StringBuilder listOfLicenseNumbersBuilder = new StringBuilder();
            bool          showAllVehicleLicenseNumber = false;
            int           countLicenseNumber          = 0;

            if (i_VehicleStatus == 0)
            {
                showAllVehicleLicenseNumber = true;
            }
            foreach (Vehicle vehicle in r_GarageDataBase.Keys)
            {
                if (showAllVehicleLicenseNumber || r_GarageDataBase[vehicle].VehicleStatusInTheGarage.Equals(i_VehicleStatus))
                {
                    listOfLicenseNumbersBuilder.AppendFormat("- {0}{1}", vehicle.LicenseNumber, Environment.NewLine);
                    countLicenseNumber++;
                }
            }
            if (countLicenseNumber == 0)
            {
                if (showAllVehicleLicenseNumber)
                {
                    throw new Exception(k_NoVehiclesInTheGarageMessage);
                }
                else
                {
                    throw new Exception(k_NoVehicleWithThisStatusMessage);
                }
            }

            return(listOfLicenseNumbersBuilder.ToString());
        }
Пример #2
0
        public void ChangeVehicleStatus(string i_LicenseNumber, Customer.eVehicleStatusInTheGarage i_NewVehicleStatus)
        {
            Vehicle desiredVehicle = getVehicleByLicenseNumber(i_LicenseNumber);

            if (desiredVehicle.Equals(null))
            {
                throw new KeyNotFoundException(k_VehicleNotFoundMessage);
            }

            r_GarageDataBase[desiredVehicle].VehicleStatusInTheGarage = i_NewVehicleStatus;
        }
Пример #3
0
        private void changeVehicleStatus()
        {
            string licenseNumber = getNotEmptyStringFromUser(k_VehicleLicenseNumber);

            if (!r_Garage.IsVehicleInTheGarage(licenseNumber))
            {
                throw new Exception(k_VehicleNotExistErrorMessage);
            }

            Customer.eVehicleStatusInTheGarage newVehicleStatus = (Customer.eVehicleStatusInTheGarage)getValidEnumOptionFromUser(k_VehicleStatus, new Customer.eVehicleStatusInTheGarage());
            r_Garage.ChangeVehicleStatus(licenseNumber, newVehicleStatus);
            Console.WriteLine("{0}Successfully changed vehicle status", Environment.NewLine);
        }
Пример #4
0
        private void showAllLicensesList()
        {
            StringBuilder listOfLicenseNumbers = new StringBuilder();
            string        userInput            = getValidNameAsStringFromUser(k_DoYouWantFilterResults);
            string        allLicensesListAcordingToStatus;

            if (isValidBooleanOptionFromUser(userInput))
            {
                Customer.eVehicleStatusInTheGarage vehicleStatus = (Customer.eVehicleStatusInTheGarage)getValidEnumOptionFromUser(k_VehicleStatus, new Customer.eVehicleStatusInTheGarage());
                allLicensesListAcordingToStatus = r_Garage.ShowListOfLicenseNumbersAccordingToStatus(vehicleStatus);
            }
            else
            {
                allLicensesListAcordingToStatus = r_Garage.ShowListOfLicenseNumbersAccordingToStatus();
            }

            listOfLicenseNumbers.AppendFormat("{0}The License Numbers Are:{0}", Environment.NewLine);
            listOfLicenseNumbers.AppendFormat(allLicensesListAcordingToStatus);


            Console.WriteLine(listOfLicenseNumbers);
        }