using System.Collections.Generic;
public static void Main()
var strategies = new List<IHourlyQuaddieStrategy>()
new CaulfieldHourlyQuaddieStrategy(),
new MetroThoroughbredHourlyQuaddieStrategy(),
new CountryThoroughbredHourlyQuaddieStrategy(),
new InternationalThoroughbredHourlyQuaddieStrategy()
public class CaulfieldHourlyQuaddieStrategy : IHourlyQuaddieStrategy
public IEnumerable<Race> SelectApplicableRaces(IEnumerable<Race> races)
=> races.Where(race => race.VenueName == "Caulfield").ToList();
public class MetroThoroughbredHourlyQuaddieStrategy : SimpleHourlyQuaddieStrategy, IHourlyQuaddieStrategy
public MetroThoroughbredHourlyQuaddieStrategy() : base(RacingType.Thoroughbred, Location.Local, CountryType.Metro)
public class CountryThoroughbredHourlyQuaddieStrategy : SimpleHourlyQuaddieStrategy
public CountryThoroughbredHourlyQuaddieStrategy() : base(RacingType.Thoroughbred, Location.Local, CountryType.Country)
public class InternationalThoroughbredHourlyQuaddieStrategy : SimpleHourlyQuaddieStrategy
public InternationalThoroughbredHourlyQuaddieStrategy() : base(RacingType.Thoroughbred, Location.International, CountryType.All)
public abstract class SimpleHourlyQuaddieStrategy : IHourlyQuaddieStrategy
private readonly RacingType racingType;
private readonly Location location;
private readonly CountryType countryType;
public SimpleHourlyQuaddieStrategy(RacingType racingType = RacingType.All, Location location = Location.All, CountryType countryType = CountryType.All)
this.racingType = racingType;
this.location = location;
this.countryType = countryType;
public IEnumerable<Race> SelectApplicableRaces(IEnumerable<Race> races)
if(this.racingType != RacingType.All)
races = races.Where(race => race.RacingType == this.racingType);
if(this.location != Location.All)
races = races.Where(race => race.Location == this.location);
if(this.countryType != CountryType.All)
races = races.Where(race => race.CountryType == this.countryType);
public enum RacingType { All, Thoroughbred, Harness, Greyhounds }
public enum Location { All, International, Local }
public enum CountryType { All, Country, Metro }
public RacingType RacingType { get; set; }
public Location Location { get; set; }
public CountryType CountryType { get; set; }
public string VenueName { get; set; }
public interface IHourlyQuaddieStrategy
IEnumerable<Race> SelectApplicableRaces(IEnumerable<Race> races);