не могу понять
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
ArrayList<Human>listChildren=new ArrayList<>();
Human children1=new Human("Бром",true,5,new ArrayList<Human>());
Human children2=new Human("Хлор",false,15,new ArrayList<Human>());
Human children3=new Human("Йод",true,6,new ArrayList<Human>());
listChildren.add(children1);
listChildren.add(children2);
listChildren.add(children3);
ArrayList<Human>listFather=new ArrayList<>();
Human father=new Human("Батьку",true,38,listChildren);
listFather.add(father);
ArrayList<Human>listMather=new ArrayList<>();
Human mather=new Human("Батьку",false,38,listChildren);
listMather.add(mather);
Human grentFather1=new Human("ГлавБатьку",true,98,listFather);
Human grentMather1=new Human("ГлавМамка",false,98,listFather);
Human grentFather2=new Human("ГлавБатьку2",true,98,listMather);
Human grentMather2=new Human("ГлавМамка2",false,98,listMather);
System.out.println(children1.toString());
System.out.println(children2.toString());
System.out.println(children3.toString());
System.out.println(father.toString());
System.out.println(mather.toString());
System.out.println(grentFather1.toString());
System.out.println(grentMather1.toString());
System.out.println(grentFather2.toString());
System.out.println(grentMather2.toString());
}
public static class Human {
//напишите тут ваш код
String name;
boolean sex;
int age;
ArrayList<Human>children;
public Human(String name,boolean sex,int age,ArrayList<Human>children){
name=this.name;
age=this.age;
sex=this.sex;
children=this.children;
}
public Human(String name,boolean sex,int age){
name=this.name;
age=this.age;
sex=this.sex;}
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;
}
}
}