все на экран выводит, все объекты созданы
помогите пожалуйста
package com.javarush.task.task08.task0824;
/*
Собираем семейство
*/
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human ded1 = new Human("ded1",true,70);
Human baba1 = new Human("baba1",false, 69);
Human ded2 = new Human("ded2", true, 75);
Human baba2 = new Human("baba2",false, 72);
Human papa = new Human("papa", true,40);
Human mama = new Human("mama", false,39);
Human child1 = new Human("child1", true,15);
Human child2 = new Human("child2", false,10);
Human child3 = new Human("child3", true,5);
System.out.println(ded1);
System.out.println(ded2);
System.out.println(baba1);
System.out.println(baba2);
System.out.println(papa);
System.out.println(mama);
System.out.println(child1);
System.out.println(child2);
System.out.println(child3);
}
public static class Human {
//напишите тут ваш код
String name;
boolean sex;
int age;
ArrayList<Human> children = new ArrayList<>();
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;
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;
}
}
}