示例#1
0
        private static void updateVehicleAndOwnerDetails(Vehicle i_Vehicle, string i_OwnerName, string i_OwnerPhoneNumber, eVehicleState i_VehicleState)
        {
            VehicleAndOwnerDetails vehicleAndOwnerDetailsByLicensePlateToUpdate = m_GarageVehicles[i_Vehicle.LicenceNumber];

            vehicleAndOwnerDetailsByLicensePlateToUpdate.OwnerVehicleState = i_VehicleState;
            vehicleAndOwnerDetailsByLicensePlateToUpdate.OwnerName         = i_OwnerName;
            vehicleAndOwnerDetailsByLicensePlateToUpdate.OwnerPhoneNumber  = i_OwnerPhoneNumber;
        }
示例#2
0
        private static VehicleAndOwnerDetails getVehicleDetailesByLicensePlate(string i_LicensePlateNumber)
        {
            VehicleAndOwnerDetails vehicleAndOwnerDetailsByLicensePlate = null;

            try
            {
                vehicleAndOwnerDetailsByLicensePlate = m_GarageVehicles[i_LicensePlateNumber];
            }
            catch (KeyNotFoundException)
            {
                throw new ArgumentException($"The vehicle with license number '{i_LicensePlateNumber}' is not in the garage!");
            }

            return(vehicleAndOwnerDetailsByLicensePlate);
        }
示例#3
0
        public static void AddNewVehicle(Vehicle i_vehicle, string i_OwnerName, string i_OwnerPhoneNumber)
        {
            string errorMessage = "";

            if (isVehicleInTheGarage(i_vehicle))
            {
                errorMessage = $"{Environment.NewLine}This vehicle exist in the garage. Changing the vehicle state to 'InRepair'.";
                updateVehicleAndOwnerDetails(i_vehicle, i_OwnerName, i_OwnerPhoneNumber, eVehicleState.InRepair);
                throw new ArgumentException(errorMessage);
            }
            else
            {
                VehicleAndOwnerDetails newVehicleAndOwnerDetailsByLicensePlate =
                    new VehicleAndOwnerDetails(i_vehicle, i_OwnerName, i_OwnerPhoneNumber);
                m_GarageVehicles.Add(i_vehicle.LicenceNumber, newVehicleAndOwnerDetailsByLicensePlate);
            }
        }
示例#4
0
        public static string DisplayVehicleInformation(string i_VehicleLicensePlate)
        {
            Vehicle vehicle = getVehicleByLicensePlate(i_VehicleLicensePlate);
            VehicleAndOwnerDetails vehicleAndOwnerDetails = getVehicleDetailesByLicensePlate(i_VehicleLicensePlate);
            StringBuilder          vehicleInfo            = new StringBuilder();

            vehicleInfo.Append("Vehicle Information:");
            vehicleInfo.AppendLine();
            vehicleInfo.Append("State - ");
            vehicleInfo.Append(vehicleAndOwnerDetails.OwnerVehicleState);
            vehicleInfo.AppendLine();
            vehicleInfo.Append("Owner Details - name: ");
            vehicleInfo.Append(vehicleAndOwnerDetails.OwnerName);
            vehicleInfo.Append(", Phone number: ");
            vehicleInfo.Append(vehicleAndOwnerDetails.OwnerPhoneNumber);
            vehicleInfo.AppendLine();
            vehicleInfo.Append(vehicle.ToString());


            return(vehicleInfo.ToString());
        }