Пример #1
0
 public void removeChild(Person barn) {
   if (this.isMale()) {
     barn.setFather(null);
   } else if (this.isFemale()) {
     barn.setMother(null);
   }
 }
Пример #2
0
 public void addChild(Person barn) {
   if (!this.children.contains(barn)) {
     if (this.isMale()) {
       barn.setFather(this);
     } else if (this.isFemale()) {
       barn.setMother(this);
     }
   }
 }
Пример #3
0
 public void setFather(Person far) {
   if (far == null) {
     if (this.father != null) {
       this.father.children.remove(this);
     }
     this.father = far;
   } else if (far.isMale()) {
     if (this.father != null) {
       this.father.children.remove(this);
     }
     this.father = far;
     this.father.children.add(this);
   }
 }
Пример #4
0
 public void setMother(Person mor) {
   if (mor == null) {
     if (this.mother != null) {
       this.mother.children.remove(this);
     }
     this.mother = mor;
   } else if (mor.isFemale()) {
     if (this.mother != null) {
       this.mother.children.remove(this);
     }
     this.mother = mor;
     this.mother.children.add(this);
   }
 }