Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
 private void AddCreatedParkingRate(ParkingRateCode parkingRateCode, IParkingRate parkingRateObject)
 {
     _parkingRatesMap.Add(parkingRateCode, parkingRateObject); // add for next time
 }
Exemplo n.º 6
0
 public ParkingTransaction(Patron patron, IParkingRate parkingRate)
 {
     _patron      = patron;
     _parkingRate = parkingRate;
 }