почему не выводятся обьекты Human child1, child2 , child3
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human child1 = new Human ("Jhon-1",true,1,null);
Human child2 = new Human ("Jhon-2",true,2,null);
Human child3 = new Human ("Jhon-3",true,3,null);
ArrayList<Human> listChilds = new ArrayList<Human> ();
listChilds.add (child1);
listChilds.add (child2);
listChilds.add (child3);
//=================================================================================
Human father = new Human("Отец",true, 30,listChilds);
Human mother = new Human("Мать",false, 40,listChilds);
ArrayList<Human> listParents = new ArrayList<Human> ();
listParents.add (father);
listParents.add (mother);
//====================================================================================
Human grFather1 = new Human ("GRANDFATHER- 1", true, 88, listParents);
Human grFather2 = new Human ("GRANDFATHER- 2", true, 80, listParents);
Human grMother1 = new Human ("GRANDMOTHER- 1", false, 84, listParents);
Human grMother2 = new Human ("GRANDMOTHER- 2", false, 76, listParents);
//===========================================================================================
System.out.println (grFather1);
System.out.println (grFather2);
System.out.println (grMother1);
System.out.println (grMother2);
System.out.println (father);
System.out.println (mother);
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;
public 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;
}
}
}