public void Execute() { var apple = new Product("Apple", Color.Green, Size.Small); var ball = new Product("Ball", Color.Green, Size.Small); var tree = new Product("Tree", Color.Green, Size.Large); var cooperS = new Product("Mini-Cooper S", Color.Red, Size.Large); Product[] products = { apple, tree, cooperS, ball }; var filterItems = new FilterItems(); Console.WriteLine("Green products:"); foreach (var product in filterItems.Filter(products, new ColorSpecification(Color.Green))) { Console.WriteLine($" - {product.Name} is green"); } Console.WriteLine(); Console.WriteLine("Green and small products"); foreach (var product in filterItems.Filter(products, new GreenAndSmallSpecification( new ColorSpecification(Color.Green), new SizeSpecification(Size.Small)))) { Console.WriteLine($" - {product.Name} is green and small"); } Console.WriteLine(); Console.WriteLine("Green cars"); var carFilter = new FilterCars(); var bentley = new Car("Bentley", Color.Green); var shevyCamaro = new Car("Shevy Camaro", Color.Green); var astonMartin = new Car("Aston Martin", Color.Black); Car[] cars = { bentley, shevyCamaro, astonMartin }; foreach (var car in carFilter.Filter(cars, new CarColorSpecification(Color.Green))) { Console.WriteLine($" - {car.Name} is a green car"); } Console.ReadLine(); }