Помогите пожалуйста, не могу понять, где ошибка?
package com.javarush.task.task07.task0724;
import java.util.*;
/*
Семейная перепись
*/
public class Solution {
public static void main(String[] args) {
Human grandPap1 = new Human("Jeff", true, 72, null, null);
Human grandPap2 = new Human("John", true, 68, null, null);
Human grandMam1 = new Human("Masha", false, 69, null, null);
Human grandMam2 = new Human("Oksana", false, 71, null, null);
Human father = new Human("Peter", true, 44, grandPap1, grandMam1);
Human mother = new Human("Julia", true, 41, grandPap2, grandMam2);
Human son1 = new Human("Billy", true, 18, father, mother);
Human son2 = new Human("Pedro", true, 15, father, mother);
Human daugther = new Human("Nelly", false, 14, father, mother);
ArrayList<Human> list = new ArrayList<>();
list.add(grandPap1);
list.add(grandPap2);
list.add(grandMam1);
list.add(grandMam2);
list.add(father);
list.add(mother);
list.add(son1);
list.add(son2);
list.add(daugther);
for(int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
}
public static class Human {
// напишите тут ваш код
String name;
boolean sex;
int age;
Human father;
Human mother;
public Human(String name, boolean sex, int age, Human father, Human mother) {
this.name = name;
this.sex = sex;
this.age = age;
this.father = father;
this.mother = mother;
}
public Human(String name, boolean sex, int age) {
this.name = name;
this.sex = sex;
this.age = age;
}
public String toString() {
String text = "";
text += "Имя: " + this.name;
text += ", пол: " + (this.sex ? "мужской" : "женский");
text += ", возраст: " + this.age;
if (this.father != null) {
text += ", отец: " + this.father.name;
}
if (this.mother != null) {
text += ", мать: " + this.mother.name;
}
return text;
}
}
}