/// <summary> /// Iterarte over the LicenseNumbersList and add all the license /// whose sataus is different from the i_FilteringStatus to /// the keys list. /// </summary> /// <param name="i_FilteringStatus"></param> /// <returns></returns> private List <string> getDifferentLicensesStatus( eVehicleStatus i_FilteringStatus) // How can we make it to be polimorfic? { List <string> keys = new List <string>(); foreach (KeyValuePair <string, VehicleDetails> pair in LicenseNumbersList) { eVehicleStatus status = pair.Value.VehicleStatus; if (!status.Equals(i_FilteringStatus)) { keys.Add(pair.Key); } } return(keys); }
public void ChangeVehicleStatus(string i_LicensePlateNumber, eVehicleStatus i_NewVehicleStatus) { int vehicleLocation = CheckIfVehicleInGarage(i_LicensePlateNumber); if (vehicleLocation == k_NotInGarage) { throw new ArgumentException("Vehicle is NOT in garage"); } eVehicleStatus oldStatus = r_VehiclesInGarageStatus[i_LicensePlateNumber]; if (!oldStatus.Equals(i_NewVehicleStatus)) { switch (oldStatus) { case eVehicleStatus.InRepair: m_CountInRepair--; break; case eVehicleStatus.Fixed: m_CountFixed--; break; case eVehicleStatus.Payed: m_CountPayed--; break; } switch (i_NewVehicleStatus) { case eVehicleStatus.InRepair: m_CountInRepair++; break; case eVehicleStatus.Fixed: m_CountFixed++; break; case eVehicleStatus.Payed: m_CountPayed++; break; } r_VehiclesInGarageStatus[i_LicensePlateNumber] = i_NewVehicleStatus; } }
/// <summary> /// Display a list of license numbers currently in the garage, with a /// filtering option based on the status of each vehicle. /// </summary> /// <param name="i_VehicleStatus"></param> /// <returns> A list of license numbers string representation </returns> public string DisplayLicenseNumbersList( eVehicleStatus i_FilteringStatus) { string licenseNumbersList; if (i_FilteringStatus.Equals(eVehicleStatus.None)) // Print all the list { licenseNumbersList = printLicenseNumbersList(LicenseNumbersList); } // Print the filtered list. else { Dictionary <string, VehicleDetails> filteredDictionary = new Dictionary <string, VehicleDetails>(LicenseNumbersList); List <string> licenses = getDifferentLicensesStatus(i_FilteringStatus); removeLicenses(filteredDictionary, licenses); licenseNumbersList = printLicenseNumbersList(filteredDictionary); // i didn't figure out how to use to string method... } return(licenseNumbersList); }