public static void Start() { List <Person> persons = new List <Person>(); persons.Add(new Person("Robert", "Male", "Single")); persons.Add(new Person("John", "Male", "Married")); persons.Add(new Person("Laura", "Female", "Married")); persons.Add(new Person("Diana", "Female", "Single")); persons.Add(new Person("Mike", "Male", "Single")); persons.Add(new Person("Bobby", "Male", "Single")); Criteria male = new CriteriaMale(); Criteria female = new CriteriaFemale(); Criteria single = new CriteriaSingle(); Criteria singleMale = new AndCriteria(single, male); Criteria singleOrFemale = new OrCriteria(single, female); Console.WriteLine("Males: "); PrintPersons(male.MeetCriteria(persons)); Console.WriteLine("\nFemales: "); PrintPersons(female.MeetCriteria(persons)); Console.WriteLine("\nSingle Males: "); PrintPersons(singleMale.MeetCriteria(persons)); Console.WriteLine("\nSingle Or Females: "); PrintPersons(singleOrFemale.MeetCriteria(persons)); }
public void Main() { List <Person> persons = new List <Person>(); persons.Add(new Person("Robert", "Male", "Single")); persons.Add(new Person("John", "Male", "Married")); persons.Add(new Person("Laura", "Female", "Married")); persons.Add(new Person("Diana", "Female", "Single")); persons.Add(new Person("Mike", "Male", "Single")); persons.Add(new Person("Bobby", "Male", "Single")); ICriteria male = new CriteriaMale(); ICriteria female = new CriteriaFemale(); ICriteria single = new CriteriaSingle(); ICriteria singleMale = new AndCriteria(single, male); ICriteria singleOrFemale = new OrCriteria(single, female); PrintPersons(male.MeetCriteria(persons)); PrintPersons(female.MeetCriteria(persons)); PrintPersons(single.MeetCriteria(persons)); PrintPersons(singleMale.MeetCriteria(persons)); PrintPersons(singleOrFemale.MeetCriteria(persons)); }