|
@@ -67,3 +67,30 @@ class Person:
|
|
|
False
|
|
|
"""
|
|
|
return self.identifier == other.identifier
|
|
|
+
|
|
|
+ def merge(self, person: "Person") -> None:
|
|
|
+ """
|
|
|
+ >>> p1 = Person("max")
|
|
|
+ >>> p1.name = "Max Mustermann"
|
|
|
+ >>> str(p1)
|
|
|
+ 'Max Mustermann'
|
|
|
+ >>> p2 = Person("max2")
|
|
|
+ >>> p2.birth_date = datetime.date(1976, 2, 1)
|
|
|
+ >>> p2.mother = Person("mother")
|
|
|
+ >>> p2.father = Person("father")
|
|
|
+ >>> str(p2)
|
|
|
+ 'unnamed (*1976-02-01)'
|
|
|
+ >>> p1.merge(p2)
|
|
|
+ >>> str(p1)
|
|
|
+ 'Max Mustermann (*1976-02-01)'
|
|
|
+ >>> p1.mother, p1.father
|
|
|
+ (Person(mother), Person(father))
|
|
|
+ """
|
|
|
+ if person.name is not None:
|
|
|
+ self.name = person.name
|
|
|
+ if person.birth_date is not None:
|
|
|
+ self.birth_date = person.birth_date
|
|
|
+ if person.mother is not None:
|
|
|
+ self.mother = person.mother
|
|
|
+ if person.father is not None:
|
|
|
+ self.father = person.father
|