public IFreeMinutesPolicy Create(Rental rental) { IFreeMinutesPolicy policy = new StandardFreeMinutesPolicy(); //If customer make a rental at early morning, PremiumFreeMiutes policy will be applied if (rental.Started.Hour < 7) { policy = new PremiumFreeMinutesPolicy(); } return(policy); }
public IFreeMinutesPolicy Create(Rental rental) { IFreeMinutesPolicy policy = new StandardFreeMinutesPolicy(); if (rental.VehicleType == VehicleType.Scooter) { policy = new ScooterFreeMinutesPolicy(); } else if (rental.GetTimeInMinutes() > 60) { policy = new VIPFreeMinutesPolicy(); } return(policy); }