private static void addANewVehicleToGarage(Garage i_Garage) { Console.WriteLine(" ===== Add New Vechile To Our Garage ==== "); SupportVehicle.eVehicleType vehicleType = chooseVechileToAdd(); Console.WriteLine("Please Type Owner Name"); string ownerName = getAlphabeatString(); Console.WriteLine("please Type Phone Number"); string phoneNumber = getANumericString(); List <string> propertiesToGet = SupportVehicle.GetPropertiesByVehicleType(vehicleType); List <string> userInputProperties = new List <string>(); foreach (string prop in propertiesToGet) { Console.WriteLine("Please Type {0}", prop); userInputProperties.Add(getNonEmptyString()); } try { bool res = i_Garage.TryAddingNewVehicleToGarage(ownerName, phoneNumber, userInputProperties, vehicleType); if (res) { Console.WriteLine("{0}{1}Sucsses Adding A New Vehicle!{1}{0}", k_BreakLine, System.Environment.NewLine); } else { Console.WriteLine("{0}{1}Vechile by the same license plate already exist in the garage{1}{0}", k_BreakLine, System.Environment.NewLine); } } catch (Exception e) { Console.WriteLine("{0}{1}Cannot Adding a New Vechile{1}{2}{1}{0}", k_BreakLine, System.Environment.NewLine, e.Message); } }
public bool TryAddingNewVehicleToGarage(string i_OwnerName, string i_PhoneNumberOfOwner, List <string> i_DataMemory, SupportVehicle.eVehicleType i_VehicleType) { bool res = true; if (!IsLicenseNumberAlrdyExists(i_DataMemory[(int)SupportVehicle.eVehicleData.LicencePlate])) { m_VehiclesInGarage.Add(i_DataMemory[(int)SupportVehicle.eVehicleData.LicencePlate], new VehicleInRepair(i_OwnerName, i_PhoneNumberOfOwner, i_DataMemory, i_VehicleType)); } else { changeVehicleConditionBackToInRepair(m_VehiclesInGarage[i_DataMemory[(int)SupportVehicle.eVehicleData.LicencePlate]].Vehicle.LicensePlate); res = false; } return(res); }
internal VehicleInRepair(string i_OwnerName, string i_PhoneNumberOfOwner, List <string> i_DataMemory, SupportVehicle.eVehicleType i_VehicleType) { r_TypeOfVehicle = SupportVehicle.CreateVehicle(i_DataMemory, i_VehicleType); m_Owner = i_OwnerName; m_PhoneNumberOfOwner = i_PhoneNumberOfOwner; m_VehicleCondition = eVehicleCondition.inRepair; }