private void addVehicleToGarage() { Vehicle vehicleToAdd = null; string licenseNumberFromuser = GarageUIUtils.getVehicleLicenseNumber(); if (GarageServices.tryGetVehicleByLicense(licenseNumberFromuser, out vehicleToAdd)) { Console.WriteLine("The Vehicle " + licenseNumberFromuser + " already Exists!"); GarageServices.ChangeVehicleStatus(vehicleToAdd, eVehicleStatus.Repaired); } else { eVehicleType vehicleType = GarageUIUtils.getVehicleType(); string modelName = GarageUIUtils.getVehicleModelName(); string wheelManfucaturerName = GarageUIUtils.getWheelManufacturerName(); string ownerName = GarageUIUtils.getVehicleOwnerName(); string ownerPhoneNum = GarageUIUtils.getVehicleOwnerPhoneNum(); try { Dictionary <string, string> uniqueVehicleProperties = GetUniquePropertiesByVehicleType(vehicleType); GarageServices.AddNewGarageEntry(vehicleType, modelName, licenseNumberFromuser, wheelManfucaturerName, ownerName, ownerPhoneNum, uniqueVehicleProperties); Console.WriteLine("Vehicle was assigned to repair."); } catch (Exception ex) { Console.WriteLine(ex.Message); } } Console.WriteLine("To return to the menu press any key."); Console.ReadKey(); }
private void displayVehicleList() { List <string> vehiclesList = new List <string>(); Console.WriteLine("Would you like to include filtering? Enter y/n."); string filter = Console.ReadLine().ToLower(); bool v_includeFilter = true; eVehicleStatus vehicleStatus = eVehicleStatus.All; if (filter == "y") { vehicleStatus = GarageUIUtils.getVehicleStatus(); vehiclesList = GarageServices.GetVehiclesListInGarage(vehicleStatus, v_includeFilter); } else if (filter == "n") { vehiclesList = GarageServices.GetVehiclesListInGarage(eVehicleStatus.All, !v_includeFilter); } else { Console.WriteLine("Invalid Input"); displayVehicleList(); } foreach (string vehicleLicenseNumber in vehiclesList) { Console.WriteLine(vehicleLicenseNumber); } }
private void changeVehicleStatus() { Vehicle vehicleToChangeStatus = null; eVehicleStatus newVehicleStatus = GarageUIUtils.getVehicleStatus(); if (GarageServices.tryGetVehicleByLicense(GarageUIUtils.getVehicleLicenseNumber(), out vehicleToChangeStatus)) { GarageServices.ChangeVehicleStatus(vehicleToChangeStatus, newVehicleStatus); } else { errorFindingVehicle(); } }
private void inflateWheelsToMax() { Vehicle vehicleToInflateWheels = null; string vehicleToInflateLicenseNumStr = GarageUIUtils.getVehicleLicenseNumber(); if (GarageServices.tryGetVehicleByLicense(vehicleToInflateLicenseNumStr, out vehicleToInflateWheels)) { GarageServices.InflateVehicleWheelsToMax(vehicleToInflateWheels); Console.WriteLine("The wheels of the vehicle with the license plate {0} was inflate to max pressure.", vehicleToInflateLicenseNumStr); Console.WriteLine("To return to the menu press any key."); Console.ReadKey(); } else { errorFindingVehicle(); } }
private void rechargeElectricVehicle() { Vehicle vehicleToRecharge = null; string vehicleToRechargeStr = GarageUIUtils.getVehicleLicenseNumber(); if (GarageServices.tryGetVehicleByLicense(vehicleToRechargeStr, out vehicleToRecharge)) { float energyToadd = GarageUIUtils.getBatteryAmountToCharge(vehicleToRecharge); GarageServices.ChargeBattery(vehicleToRechargeStr, energyToadd, vehicleToRecharge); Console.WriteLine("Recharge has succeed, charged {0} minutes the battery of the vehicle with the license plate {1}.", energyToadd, vehicleToRechargeStr); Console.WriteLine("To return to the menu press any key."); Console.ReadKey(); } else { errorFindingVehicle(); } }
private Dictionary <string, string> GetUniquePropertiesByVehicleType(eVehicleType vehicleType) { Dictionary <string, string> uniqueVehicleProperties = new Dictionary <string, string>(); string firstPropertyValue = string.Empty; string SecPropertyValue = string.Empty; switch (vehicleType) { case eVehicleType.ElectricCar: firstPropertyValue = GarageUIUtils.getCarColor(); SecPropertyValue = GarageUIUtils.getNumberOfDoorsInCar(); addVehicleUniqueProperties(uniqueVehicleProperties, GarageConstants.k_KeyColor, firstPropertyValue, GarageConstants.k_KeyNumOfDoors, SecPropertyValue); break; case eVehicleType.FuelCar: firstPropertyValue = GarageUIUtils.getCarColor(); SecPropertyValue = GarageUIUtils.getNumberOfDoorsInCar(); addVehicleUniqueProperties(uniqueVehicleProperties, GarageConstants.k_KeyColor, firstPropertyValue, GarageConstants.k_KeyNumOfDoors, SecPropertyValue); break; case eVehicleType.ElectricMotorcycle: firstPropertyValue = GarageUIUtils.getMotorcycleEngineVolume(); SecPropertyValue = GarageUIUtils.getMotorcycleLicenseType(); addVehicleUniqueProperties(uniqueVehicleProperties, GarageConstants.k_KeyEngineVolume, firstPropertyValue, GarageConstants.k_KeyLicenseType, SecPropertyValue); break; case eVehicleType.FuelMotorcycle: firstPropertyValue = GarageUIUtils.getMotorcycleEngineVolume(); SecPropertyValue = GarageUIUtils.getMotorcycleLicenseType(); addVehicleUniqueProperties(uniqueVehicleProperties, GarageConstants.k_KeyEngineVolume, firstPropertyValue, GarageConstants.k_KeyLicenseType, SecPropertyValue); break; case eVehicleType.FuelTruck: firstPropertyValue = GarageUIUtils.DoesContainsHazardousMaterials(); SecPropertyValue = GarageUIUtils.GetTruckMaxLoadingWeight(); addVehicleUniqueProperties(uniqueVehicleProperties, GarageConstants.k_CarryigHazardousMaterial, firstPropertyValue, GarageConstants.k_MaxLoadingWeight, SecPropertyValue); break; default: throw new ArgumentException("Invalid Menu Option!"); } return(uniqueVehicleProperties); }
private void showGarageEntryData() { Vehicle vehicleToShowInfo = null; string garageEntryData = string.Empty; string vehicleToShowInfoStr = GarageUIUtils.getVehicleLicenseNumber(); if (GarageServices.tryGetVehicleByLicense(vehicleToShowInfoStr, out vehicleToShowInfo)) { Console.WriteLine("Printing Garage Entry Data:"); garageEntryData = GarageServices.showGarageEntryData(vehicleToShowInfo); Console.Clear(); Console.WriteLine(garageEntryData); Console.WriteLine("To return to the menu press any key."); Console.ReadKey(); } else { errorFindingVehicle(); } }
private void refuelCar() { Vehicle vehicleToFuel = null; string vehicleToFuelStr = GarageUIUtils.getVehicleLicenseNumber(); Console.WriteLine("Please Enter amount of fuel to Add."); float fuelToadd = float.Parse(Console.ReadLine()); eFuelType fuelType = GarageUIUtils.getFuelTypeFromUser(); if (GarageServices.tryGetVehicleByLicense(vehicleToFuelStr, out vehicleToFuel)) { GarageServices.AddFuel(vehicleToFuelStr, fuelToadd, (int)fuelType, vehicleToFuel); Console.WriteLine("Refuel has succeed, Added {0} liters to the vehicle with the license plate {1}.", fuelToadd, vehicleToFuelStr); Console.WriteLine("To return to the menu press any key."); Console.ReadKey(); } else { errorFindingVehicle(); } }