Beispiel #1
0
        static void Main(string[] args)
        {
            List <Person> people = new List <Person>()
            {
                new Person("Robert", "Male", "Single"),
                new Person("Jhon", "Male", "Married"),
                new Person("Laura", "Female", "Married"),
                new Person("Diana", "Female", "Single"),
                new Person("Mike", "Male", "Single"),
                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);

            Console.WriteLine("Male: ");
            PrintPeople(male.MeetCriteria(people));

            Console.WriteLine("\nFemale: ");
            PrintPeople(female.MeetCriteria(people));

            Console.WriteLine("\nSingle Male: ");
            PrintPeople(singleMale.MeetCriteria(people));

            Console.WriteLine("\nSingle Or Female: ");
            PrintPeople(singleOrFemale.MeetCriteria(people));

            Console.Read();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            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("Females: ");
            printPersons(female.meetCriteria(persons));

            Console.WriteLine("Single Males: ");
            printPersons(singleMale.meetCriteria(persons));

            Console.WriteLine("Single or Females: ");
            printPersons(singleOrFemale.meetCriteria(persons));

            Console.ReadKey();
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            var persons = new List <Person>
            {
                new Person("Robert", "Male", "Single"),
                new Person("John", "Male", "Married"),
                new Person("Laura", "Female", "Married"),
                new Person("Diana", "Female", "Single"),
                new Person("Mike", "Male", "Single"),
                new Person("Bobby", "Male", "Single")
            };

            var male           = new CriteriaMale();
            var female         = new CriteriaFemale();
            var single         = new CriteriaSingle();
            var singleMale     = new AndCriteria(single, male);
            var 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));

            Console.ReadKey();
        }