// car: i_VehicelParams = ( enum color, enum num_OfDoors) // motorcycle: i_VehicelParams = ( float engine volume, enum licence) // Truck: i_VehicelParams = ( bool IsTruckRefrigerated, float TrunkSize) public void AddVehicleToGarage(HoldAddGarageVehicleParams i_UserParams, params float[] i_VehicelParams) // (1) in menu { Vehicle myVehicle = null; VehicleInGarage vehicleInGarage; bool vehicleExist = r_VehiclesDataBase.TryGetValue(i_UserParams.LicencePlate, out vehicleInGarage); if (vehicleExist) { this.ChangeStatusOfListedCar(i_UserParams.LicencePlate, eVehicleStatus.Repairing); throw new ArgumentException(k_ErrVehicleExsit); } else { try { myVehicle = VehicalGarageCreator.CreateVehicleForGarage(i_UserParams, i_VehicelParams); if (myVehicle == null) { throw new ArgumentException(k_ErrVehicleNotSupported); } else { vehicleInGarage = new VehicleInGarage(myVehicle, i_UserParams.ClientName, i_UserParams.PhoneNumber); r_VehiclesDataBase.Add(i_UserParams.LicencePlate, vehicleInGarage); } } catch (Exception ex) { throw ex; } } }
//EX3 public void ChangeTheStatusOfVehicleInTheGarage(string i_LicenseNumber, eVehicleStatus i_NewStatus) { VehicleInGarage updateVehicle = m_CustomerDetailsByLicenseNumber[i_LicenseNumber]; updateVehicle.VehicleStatus = i_NewStatus; m_CustomerDetailsByLicenseNumber[i_LicenseNumber] = updateVehicle; }
public void ChargeElectricVehicle(string i_LicensePlate, float i_MinutesToCharge) { VehicleInGarage requestedVehicle = SearchForVehicleInGarage(i_LicensePlate); float hoursToCharge = i_MinutesToCharge / 60; bool isElectricEngine = requestedVehicle.TheVehicle.VehicleEngine is ElectricEngine; if (requestedVehicle != null) { if (isElectricEngine) { ElectricEngine vehicleEngine = requestedVehicle.TheVehicle.VehicleEngine as ElectricEngine; if (requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy + hoursToCharge <= requestedVehicle.TheVehicle.VehicleEngine.MaximumAmountOfEnergy) { requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy += hoursToCharge; requestedVehicle.TheVehicle.VehicleEngine.PercentOfEnergyLeft = (requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy / requestedVehicle.TheVehicle.VehicleEngine.MaximumAmountOfEnergy) * 100; } else { float maxValue = (requestedVehicle.TheVehicle.VehicleEngine.MaximumAmountOfEnergy - requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy) * 60; throw new ValueOutOfRangeException(0, maxValue); } } else { throw new ArgumentException("The requested vehicle is not electric!"); } } else { throw new ArgumentException("The requested vehicle does not run on gas!"); } }
public VehicleInGarage SearchForVehicleInGarage(string i_LicensePlate) { VehicleInGarage requestedVehicle = null; m_VehiclesDictionary.TryGetValue(i_LicensePlate, out requestedVehicle); return(requestedVehicle); }
public void AddWheels(string i_LicenseNumber, string i_ManufacturerName, float i_CurrentAirPressure) { m_CurrentVehicleInGarage = m_VehiclesInGarage[i_LicenseNumber]; for (int i = 0; i < m_CurrentVehicleInGarage.Vehicle.NumberOfWheels; ++i) { m_CurrentVehicleInGarage.Vehicle.AddWheel(i_ManufacturerName, i_CurrentAirPressure); } }
public VehicleInGarage GetVehicleByLicensePlate(string i_LicensePlate) { VehicleInGarage TheVehicle = null; m_VehiclesInGarage.TryGetValue(i_LicensePlate, out TheVehicle); return(TheVehicle); }
public void AddCarToGarage(string i_OwnerName, string i_OwnerPhone, string i_LicenseNumber, int i_VehicleTypeInt) { Vehicle newVehicle; Vehicle.eVehicleType vehicleType = (Vehicle.eVehicleType)i_VehicleTypeInt; newVehicle = Vehicle.CreateVehicle(vehicleType, i_LicenseNumber); m_CurrentVehicleInGarage = new VehicleInGarage(i_OwnerName, i_OwnerPhone, newVehicle); r_VehiclesInGarage.Add(i_LicenseNumber, m_CurrentVehicleInGarage); m_CurrentVehicleInGarage.OwnerVehicle.VehicleType = vehicleType; }
public override string ToString() { StringBuilder clientCardStr = new StringBuilder(); clientCardStr.AppendLine(VehicleInGarage.ToString()); clientCardStr.AppendLine(string.Format("Owner name: {0}", Owner)); clientCardStr.AppendLine(string.Format("Owner phone number: {0}", OwnerPhoneNumber)); clientCardStr.AppendLine(string.Format("Status: {0}", Status.ToString())); return(clientCardStr.ToString()); }
public void InflateAllWheelsToMax(string i_LicensePlate) { VehicleInGarage vehicleWanted = find(i_LicensePlate); if (vehicleWanted == null) { throw new Exception("Inflating failed. Vehicle's license plate wasn't found"); } vehicleWanted.Vehicle.InflateAllWheelsToMaxCapaciy(); }
public void chargeVehicle(string i_LicencePlate, float i_AddedTime) { VehicleInGarage vehicleInGarage = find(i_LicencePlate); if (vehicleInGarage == null) { throw new Exception("Can't charge! The vehicle's license plate is not found"); } vehicleInGarage.Vehicle.FillTank(i_AddedTime, EnergyType.Electricity); }
public void ChangeVehicleStatus(string i_LicenseNumber, eStatus i_CarStatus) { VehicleInGarage vehicleAlreadyInside = IsExistsInGarage(i_LicenseNumber); if (vehicleAlreadyInside == null) { throw new MissingVehicleException(i_LicenseNumber); } vehicleAlreadyInside.CurrentStatus = i_CarStatus; }
public string GetVehicleDetails(string i_LicenseNumber) { VehicleInGarage DemandVehicle = IsExistsInGarage(i_LicenseNumber); if (DemandVehicle == null) { throw new MissingVehicleException(i_LicenseNumber); } return(DemandVehicle.ToString()); }
public void ChangeVehicleState(string i_LicensePlate, VehicleState i_VehicleState) { VehicleInGarage vehicle = find(i_LicensePlate); if (vehicle == null) { throw new Exception("Changing state failed. Vehicle's license plate wasn't found"); } vehicle.VehicleState = i_VehicleState; }
public void fuelVehicle(string i_LicencePlate, EnergyType i_FuelType, float i_AddedFuel) { VehicleInGarage vehicleInGarage = find(i_LicencePlate); if (vehicleInGarage == null) { throw new Exception("Can't fuel! The vehicle's license plate is not found"); } vehicleInGarage.Vehicle.FillTank(i_AddedFuel, i_FuelType); }
public bool SetCurrentVehicleInGarage(string i_LicenseNumber) { bool isInGarage = false; if (IsLicenseInGarage(i_LicenseNumber)) { m_CurrentVehicleInGarage = r_VehiclesInGarage[i_LicenseNumber]; isInGarage = true; } return(isInGarage); }
public int GetEngineType(string i_LicenseNumber) { if (CheckIfLicenseNumberInGarage(i_LicenseNumber)) { m_CurrentVehicleInGarage = m_VehiclesInGarage[i_LicenseNumber]; return(m_CurrentVehicleInGarage.Vehicle.GetEngineType()); } else { throw new ArgumentException("This vehicle not in the garage."); } }
public void AddVehicle(VehicleInGarage m_VehicleToAdd) { VehicleInGarage vehicleWithSameLicensePlate = find(m_VehicleToAdd.Vehicle.LicensePlate); if (vehicleWithSameLicensePlate != null) { vehicleWithSameLicensePlate.VehicleState = VehicleState.InRepair; throw new Exception("Vehicle Is Already in the garage! The state of the vehicle is changed to: in repair"); } m_Vehicles.Add(m_VehicleToAdd); }
public string ShowVehicleDetails(string i_LicenseNumber) { if (CheckIfLicenseNumberInGarage(i_LicenseNumber)) { m_CurrentVehicleInGarage = m_VehiclesInGarage[i_LicenseNumber]; return(m_CurrentVehicleInGarage.ToString()); } else { throw new ArgumentException("The License number not found in the garage."); } }
public bool SetCurrentVehicleInGarage(string i_LicenseNumber) { bool vehicleExsist = false; if (CheckIfLicenseNumberInGarage(i_LicenseNumber)) { m_CurrentVehicleInGarage = m_VehiclesInGarage[i_LicenseNumber]; vehicleExsist = true; } return(vehicleExsist); }
private VehicleInGarage find(string i_LicensePlate) { VehicleInGarage vehicleWanted = null; foreach (VehicleInGarage vehicle in m_Vehicles) { if (vehicle.Vehicle.LicensePlate == i_LicensePlate) { vehicleWanted = vehicle; } } return(vehicleWanted); }
public void InsertVehicleToGarage(string i_OwnerName, string i_OwnerPhoneNumber, string i_LicenseNumber, int i_VehicleType) { if (!CheckIfLicenseNumberInGarage(i_LicenseNumber)) { Vehicle newVehicle = CreateVehicle.createVehicle(i_LicenseNumber, i_VehicleType); m_CurrentVehicleInGarage = new VehicleInGarage(newVehicle, i_OwnerName, i_OwnerPhoneNumber); m_VehiclesInGarage.Add(i_LicenseNumber, m_CurrentVehicleInGarage); } else { throw new ArgumentException("This vehicle already in the garage."); } }
public void ChangeVehicleInGarageStatus(string i_LicenseNumber, int i_NewStatus) { if (CheckIfLicenseNumberInGarage(i_LicenseNumber)) { VehicleInGarage.eVehicleStatus newStatus = (VehicleInGarage.eVehicleStatus)i_NewStatus; m_CurrentVehicleInGarage = m_VehiclesInGarage[i_LicenseNumber]; m_CurrentVehicleInGarage.VehicleStatus = newStatus; } else { throw new ArgumentException("This vehicle not in the garage."); } }
public void AddCarToGarage(string i_OwnerName, string i_OwnerPhone, string i_LicenseNumber, int i_VehicleType) { Vehicle newVehicle; CreateVehicle.eVehicleType vehicleType = (CreateVehicle.eVehicleType)i_VehicleType; if (IsLicenseInGarage(i_LicenseNumber)) { throw new ArgumentException("The vehicle already exists in the garage!"); } else { newVehicle = CreateVehicle.createVehicle(vehicleType, i_LicenseNumber); m_CurrentVehicleInGarage = new VehicleInGarage(i_OwnerName, i_OwnerPhone, newVehicle); r_VehiclesInGarage.Add(i_LicenseNumber, m_CurrentVehicleInGarage); } }
public void AddAirPressure(string i_LicenseNumber) { VehicleInGarage vehicleToReapair = IsExistsInGarage(i_LicenseNumber); if (vehicleToReapair == null) { throw new MissingVehicleException(i_LicenseNumber); } else { foreach (Wheel wheels in vehicleToReapair.Vehicle.Wheels) { wheels.FillToMaximum(); } } }
public bool ChangeStatusOfVehicleInGarage(string i_LicensePlate, VehicleInGarage.eVehicleStatus i_NewStatus) { VehicleInGarage requestedVehicle = SearchForVehicleInGarage(i_LicensePlate); bool statusChanged; if (requestedVehicle != null) { requestedVehicle.VehicleStatus = i_NewStatus; statusChanged = true; } else { statusChanged = !true; } return(statusChanged); }
public bool CheckIfVehicleExistsAndChangeStatus(string i_LicenseNumber, out string o_MsgToUser) { bool isVehicleExists = IsLicenseInGarage(i_LicenseNumber); if (isVehicleExists) { m_CurrentVehicleInGarage = r_VehiclesInGarage[i_LicenseNumber]; m_CurrentVehicleInGarage.VehicleStatus = VehicleInGarage.eVehicleStatus.InRepair; o_MsgToUser = "******"; } else { o_MsgToUser = "******"; } return(!isVehicleExists); }
public void ChargeVehicle(string i_LicenseNumber, float i_TimeToCharge) { VehicleInGarage vehicleInGarage = IsExistsInGarage(i_LicenseNumber); if (vehicleInGarage == null) { throw new MissingVehicleException(i_LicenseNumber); } if (vehicleInGarage.Vehicle.EngineType is Fuel) { throw new EngineTypeException(); } else { (vehicleInGarage?.Vehicle.EngineType)?.AddEnergy(i_TimeToCharge); } }
internal void AddVehicle(Dictionary <string, Object> i_VehicleInGarageInfo) { Vehicle OwnerVehicle = Validation.ObjectToVehicle(i_VehicleInGarageInfo["Vehicle"]); string LicenseNumber = ((string)OwnerVehicle.m_LicenseNumber); if (this.m_VehivleInGarageDict.ContainsKey(LicenseNumber)) { // // Should print a Messege that Vehicle is in allready in garage // this.m_VehivleInGarageDict[LicenseNumber].m_VehicleStatus = VehicleInGarage.eVehicleStatus.Fixing; } else { VehicleInGarage OwnerVehicleInGarage = new VehicleInGarage(i_VehicleInGarageInfo); this.m_VehivleInGarageDict[LicenseNumber] = OwnerVehicleInGarage; } }
public bool CheckIfVehicleExistAndChangeStatus(string i_LicenseNumber, out string o_MessageToUser) { o_MessageToUser = string.Empty; bool isVehicleExists = IsLicenseInGarage(i_LicenseNumber); if (isVehicleExists) { m_CurrentVehicleInGarage = r_VehiclesInGarage[i_LicenseNumber]; m_CurrentVehicleInGarage.VehicleStatus = VehicleInGarage.eVehicleStatus.InRepair; o_MessageToUser = "******"; } else { o_MessageToUser = "******"; } return(!isVehicleExists); }
public bool RefuleVechileWithFuelEngine(string i_LicensePlate, FuelEngine.eFuelType i_RequestedFuelType, float i_AmountOfFuelToFill) { VehicleInGarage requestedVehicle = SearchForVehicleInGarage(i_LicensePlate); bool refuelDone; if (requestedVehicle != null) { bool isFuelEngine = requestedVehicle.TheVehicle.VehicleEngine is FuelEngine; if (isFuelEngine) { FuelEngine vehicleEngine = requestedVehicle.TheVehicle.VehicleEngine as FuelEngine; if (vehicleEngine.TheFuelType == i_RequestedFuelType) { if (requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy + i_AmountOfFuelToFill <= requestedVehicle.TheVehicle.VehicleEngine.MaximumAmountOfEnergy) { requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy += i_AmountOfFuelToFill; requestedVehicle.TheVehicle.VehicleEngine.PercentOfEnergyLeft = (requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy / requestedVehicle.TheVehicle.VehicleEngine.MaximumAmountOfEnergy) * 100; } else { float maxValue = requestedVehicle.TheVehicle.VehicleEngine.MaximumAmountOfEnergy - requestedVehicle.TheVehicle.VehicleEngine.CurrentAmountOfEnergy; throw new ValueOutOfRangeException(0, maxValue); } } else { throw new ArgumentException("Wrong fuel type!"); } } else { throw new ArgumentException("The requested vehicle does not run on gas!"); } refuelDone = true; } else { refuelDone = !true; } return(refuelDone); }