Не пойму, что не нравится валидатору
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
ArrayList<Human> detidetey = new ArrayList<>(0);
Human ch1 = new Human("Вася", true, 9, detidetey);
Human ch2 = new Human("Маша", false, 8, detidetey);
Human ch3 = new Human("Петя", true, 11, detidetey);
ArrayList<Human> deti = new ArrayList<>();
deti.add(ch1);
deti.add(ch2);
deti.add(ch3);
Human mom = new Human("Ира", false, 33, deti);
Human dad = new Human("Андрей", true, 34, deti);
ArrayList<Human> papa = new ArrayList<>();
papa.add(dad);
ArrayList<Human> mama = new ArrayList<>();
mama.add(mom);
Human grandm1 = new Human("Галя", false, 63, mama);
Human grandf1 = new Human("Виталий", true, 62, mama);
Human grandm2 = new Human("Нина", false, 64, papa);
Human grandf2 = new Human("Игорь", true, 66, papa);
System.out.println(ch1);
System.out.println(ch2);
System.out.println(ch3);
System.out.println(mom);
System.out.println(dad);
System.out.println(grandm1);
System.out.println(grandf1);
System.out.println(grandf2);
System.out.println(grandm2);
}
public static class Human {
//напишите тут ваш код
String name;
boolean sex;
int age;
ArrayList<Human> children;
public Human(String name, boolean sex, int age, ArrayList<Human> list) {
this.name = name;
this.sex = sex;
this.age = age;
}
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;
}
}
}