Валидатор не принял. Не могу понять, что его не устраивает. Помогите разобраться, пожалуйста.
package com.javarush.task.task08.task0824;
/*
Собираем семейство
*/
import java.util.ArrayList;
import java.util.Collections;
public class Solution {
public static void main(String[] args) {
ArrayList<Human> chirdrenNull = new ArrayList<>();
Human children1 = new Human("Ваня", true, 10, chirdrenNull);
Human children2 = new Human("Катя", false, 12, chirdrenNull);
Human children3 = new Human("Антон", true, 5, chirdrenNull);
ArrayList<Human> childrens1 = new ArrayList<>();
Collections.addAll(childrens1, children1, children2, children3);
ArrayList<Human> childrens2 = new ArrayList<>();
ArrayList<Human> childrens3 = new ArrayList<>();
Human father = new Human("Сергей", true, 35, childrens1);
Human mother = new Human("Светлана", false, 30, childrens1);
Collections.addAll(childrens2, father);
Collections.addAll(childrens3, mother);
Human ded1 = new Human("Акакий", true, 70, childrens2);
Human babka2 = new Human("Зоя", false, 65, childrens2);
Human ded2 = new Human("Афанасий", true, 71, childrens3);
Human babka1 = new Human("Зина", false, 65, childrens3);
ArrayList<Human> people = new ArrayList<>();
Collections.addAll(people, ded1, babka1, ded2, babka2, father, mother);
for (int i = 0; i < people.size(); i++) {
System.out.println(people.get(i));
}
}
public static class Human {
String name;
boolean sex;
int age;
ArrayList<Human> children;
Human(String name, boolean sex, int age, ArrayList<Human> children) {
this.name = name;
this.sex = sex;
this.age = age;
this.children = children;
}
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;
}
}
}
/*
Собираем семейство
1. Создай класс Human с полями имя (String), пол (boolean), возраст (int), дети (ArrayList<Human>).
2. Создай объекты и заполни их так, чтобы получилось: два дедушки, две бабушки, отец, мать, трое детей.
3. Вывести все объекты Human на экран.
Требования:
1. Программа должна выводить текст на экран.
2. Класс Human должен содержать четыре поля.
3. Класс Human должен содержать один метод.
4. Класс Solution должен содержать один метод.
5. Программа должна создавать объекты и заполнять их так, чтобы получилось: два дедушки, две бабушки, отец, мать, трое детей и выводить все объекты Human на экран.
*/