// created the function as virtual to have an extension point without overriding the // entire class implementation, only the location creation method. public virtual IParkingRate CreateParkingRate(ParkingRateCode parkingRateCode) { IParkingRate parkingRate = RetriveExistingParkingRate(parkingRateCode); if (parkingRate != null) { return(parkingRate); } parkingRate = GenerateParkingRateObject(parkingRateCode); AddCreatedParkingRate(parkingRateCode, parkingRate); return(parkingRate); }
internal IParkingRate GetParkingRate(DateTime entryDateTime, DateTime exitDateTime) { IParkingRate appliedParkingRate = null; foreach (var parkingRate in parkingRates) { if (appliedParkingRate == null) { if (parkingRate.DoesRateApply(entryDateTime, exitDateTime)) { appliedParkingRate = parkingRate; } } } return(appliedParkingRate); }
protected virtual IParkingRate GenerateParkingRateObject(ParkingRateCode parkingRateCode) { IParkingRate parkingRate = null; switch (parkingRateCode) { case ParkingRateCode.EarlyBird: { parkingRate = CreateEarlyBirdRateObject(); break; } case ParkingRateCode.NightRate: { parkingRate = CreateNightRateObject(); break; } case ParkingRateCode.WeekendRate: { parkingRate = CreateWeekendRateObject(); break; } case ParkingRateCode.StandardHourRate: case ParkingRateCode.StandardCalendarDayRate: { parkingRate = CreateStandardRateObject(); break; } default: { parkingRate = CreateStandardRateObject(); break; } } return(parkingRate); }
public virtual IParkingRate CreateParkingRate(RateName rateType) { IParkingRate parkingRate = null; switch (rateType) { case RateName.Standard: parkingRate = new StandardRate("Standard Rate"); break; case RateName.Night: parkingRate = new NightRate("Night Rate"); break; case RateName.EarlyBird: parkingRate = new EarlyBirdRate("Early Bird Rate"); break; case RateName.Weekend: parkingRate = new WeekendRate("Weekend Rate"); break; } return(parkingRate); }
private void AddCreatedParkingRate(ParkingRateCode parkingRateCode, IParkingRate parkingRateObject) { _parkingRatesMap.Add(parkingRateCode, parkingRateObject); // add for next time }
public ParkingTransaction(Patron patron, IParkingRate parkingRate) { _patron = patron; _parkingRate = parkingRate; }