public void AddNewVehicleToGarage(VehiclesInGarage i_NewVehicleToGarage) { VehiclesInGarage existVehicleInGarage; if (m_VehiclesInGarage.TryGetValue(i_NewVehicleToGarage.VehicleInfo.LicenseNumber, out existVehicleInGarage)) { existVehicleInGarage.VehicleStatus = eVehicleStatuses.InRepair; throw new Exception(string.Format( "The vehicle is already in garage!{0}The vehicle status has changed to 'In repair'", Environment.NewLine)); } else { m_VehiclesInGarage.Add(i_NewVehicleToGarage.VehicleInfo.LicenseNumber, i_NewVehicleToGarage); } }
public void ChangeStateOfVehicleInGarage(string i_License, GarageVehicleProfile.eStateOfVehicle i_NewVehicleState) { try { if (VehiclesInGarage.ContainsKey(i_License)) { VehiclesInGarage[i_License].VehicleStatus = i_NewVehicleState; string msg = string.Format("The vehicle with license No: {0} status successfully changed for {1}!", i_License, i_NewVehicleState); Console.WriteLine(msg); } } catch (KeyNotFoundException ex) { string msg = string.Format( @"The requested license {0} for the status change has not found in the garage system", i_License.ToString()); } }