где ошибка?
package com.javarush.task.task08.task0824;
/*
Собираем семейство
*/
import java.util.ArrayList;
import java.util.Arrays;
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human child1 = new Human("rymma", false, 26);
Human child2 = new Human("alya", false, 16);
Human child3 = new Human("kamil", true, 40);
Human father = new Human("vova", true, 49, child1, child2, child3);
Human mother = new Human("tania", false, 49, child1, child2, child3);
Human dad2 = new Human("stepa", true, 90, mother);
Human granny1 = new Human("valya", false, 70, father);
Human granny2 = new Human("rimma", false, 86, mother);
Human dad1 = new Human("vitya", true, 55, father);
ArrayList<Human> humans = new ArrayList<>(Arrays.asList(dad1, dad2, granny1, granny2, father, mother, child1, child2, child3));
for (Human s : humans)
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) {
this.name = name;
this.sex = sex;
this.age = age;
}
public Human(String name, boolean sex, int age, Human ...children) {
this.name = name;
this.sex = sex;
this.age = age;
this.children = new ArrayList<>(Arrays.asList(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;
}
}
}