private static void setPerson2(PersonRelationship personPair, Person firstPerson, Person otherPerson)
 {
     if (firstPerson.IsYoungerThan(otherPerson))
     {
         personPair.Person2 = otherPerson;
     }
     else
     {
         personPair.Person2 = firstPerson;
     }
 }
Example #2
0
 public Pair(Person person1, Person person2)
 {
     if (person1.IsOlderThan(person2))
     {
         OlderPerson = person1;
         YongerPerson = person2;
     }
     else {
         OlderPerson = person2;
         YongerPerson = person1;
     }
 }
Example #3
0
        private void DetermineOrder()
        {
            if ((PersonOne == null) || (PersonTwo == null))
            {
                return;
            }

            if (PersonOne.BirthDate > PersonTwo.BirthDate)
            {
                var temp = PersonOne;
                PersonOne = PersonTwo;
                PersonTwo = temp;
            }
        }
Example #4
0
 private static MatchingResult ComparePersons(Person first, Person second)
 {
     var r = new MatchingResult();
     if (first.BirthDate < second.BirthDate)
     {
         r.FirstPerson = first;
         r.SecondPerson = second;
     }
     else
     {
         r.FirstPerson = second;
         r.SecondPerson = first;
     }
     r.AgeDifference = r.SecondPerson.BirthDate - r.FirstPerson.BirthDate;
     return r;
 }
Example #5
0
        public AgeDistance(Person person1, Person person2)
        {
            if (person1 == null) throw new ArgumentNullException("person1");
            if (person2 == null) throw new ArgumentNullException("person2");

            if (person1.BirthDate < person2.BirthDate)
            {
                Person1 = person1;
                Person2 = person2;
            }
            else
            {
                Person1 = person2;
                Person2 = person1;
            }

            Distance = Person2.BirthDate - Person1.BirthDate;
        }
Example #6
0
        internal static FindResult Compare(Person person1, Person person2)
        {
            var result = new FindResult();

            if (person1.BirthDate < person2.BirthDate)
            {
                result.OlderPerson = person1;
                result.YoungerPerson = person2;
            }
            else
            {
                result.OlderPerson = person2;
                result.YoungerPerson = person1;
            }

            result.AgeDifference = result.YoungerPerson.BirthDate - result.OlderPerson.BirthDate;

            return result;
        }
Example #7
0
 public void Add(Person p)
 {
     _list.Add(p.BirthDate, p);
 }
Example #8
0
 public bool IsOlderThan(Person person)
 {
     return this.BirthDate > person.BirthDate;
 }
Example #9
0
 public RankedPair(Person younger, Person older)
 {
     Younger = younger;
     Older = older;
     AgeGap = Older.BirthDate - Younger.BirthDate;
 }
Example #10
0
 public FinderResult(Person firstPerson, Person secondPerson)
 {
     YoungerPerson = firstPerson.BirthDate < secondPerson.BirthDate ? firstPerson : secondPerson;
     OlderPerson = firstPerson.BirthDate > secondPerson.BirthDate ? firstPerson : secondPerson;
 }
 public FinderResult(Person younger, Person older)
 {
     Younger = younger;
       Older = older;
       BirthDateDifference = older.BirthDate - younger.BirthDate;
 }
Example #12
0
 public bool Equals(Person other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Name, Name) && other.BirthDate.Equals(BirthDate);
 }
Example #13
0
 public bool IsYoungerThan(Person otherPerson)
 {
     if (BirthDate < otherPerson.BirthDate)
         return true;
     return false;
 }