Подскажите где ошибка ?
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
1. Создай класс Human с полями имя (String), пол (boolean), возраст (int), дети (ArrayList<Human>).
2. Создай объекты и заполни их так, чтобы получилось: два дедушки, две бабушки, отец, мать, трое детей.
3. Выведи все объекты Human на экран (Подсказка: используй метод toString() класса Human).
Требования:
1. Программа должна выводить текст на экран.
2. Класс Human должен содержать четыре поля.
3. Класс Human должен содержать один метод.
4. Класс Solution должен содержать один метод.
5. Программа должна создавать объекты и заполнять их так, чтобы получилось: два дедушки, две бабушки, отец, мать, трое детей и выводить все объекты Human на экран.
*/
public class Solution {
public static void main(String[] args) {
ArrayList<Human> child= new ArrayList<>();
child.add(new Human("Melania",true,1));
child.add(new Human("Vasilisa",true,12));
child.add(new Human("Zlata",false,14));
child.add(new Human("Alla",true,46));
child.add(new Human("Sergey",true,48));
child.add(new Human("Galy",true,75));
child.add(new Human("Gena",true,78));
child.add(new Human("Nady",true,80));
child.add(new Human("Gena",true,76));
for (Human s:child)
System.out.println(s);
}
public static class Human {
String name;
boolean sex;
int age;
ArrayList<Human> children;
public Human(String name, boolean sex, int age, Human... human) {
this.name = name;
this.age = age;
this.sex = sex;
ArrayList<Human> children =new ArrayList<>();
}
public String toString() {
String text = "";
text += "Имя: " + this.name;
text += ", пол: " + (this.sex ? "мужской" : "женский");
text += ", возраст: " + this.age;
int childCount = this.children.size();
if (childCount > 0) {
text += ", дети: " + this.children.get(0).name;
for (int i = 1; i < childCount; i++) {
Human child = this.children.get(i);
text += ", " + child.name;
}
}
return text;
}
}
}