private static void setPerson2(PersonRelationship personPair, Person firstPerson, Person otherPerson) { if (firstPerson.IsYoungerThan(otherPerson)) { personPair.Person2 = otherPerson; } else { personPair.Person2 = firstPerson; } }
public Pair(Person person1, Person person2) { if (person1.IsOlderThan(person2)) { OlderPerson = person1; YongerPerson = person2; } else { OlderPerson = person2; YongerPerson = person1; } }
private void DetermineOrder() { if ((PersonOne == null) || (PersonTwo == null)) { return; } if (PersonOne.BirthDate > PersonTwo.BirthDate) { var temp = PersonOne; PersonOne = PersonTwo; PersonTwo = temp; } }
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; }
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; }
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; }
public void Add(Person p) { _list.Add(p.BirthDate, p); }
public bool IsOlderThan(Person person) { return this.BirthDate > person.BirthDate; }
public RankedPair(Person younger, Person older) { Younger = younger; Older = older; AgeGap = Older.BirthDate - Younger.BirthDate; }
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; }
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); }
public bool IsYoungerThan(Person otherPerson) { if (BirthDate < otherPerson.BirthDate) return true; return false; }