Помогите пожалуйста)
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
ArrayList<Human> c0 = new ArrayList<>();
Human child1 = new Human("Павел",true,12,c0);
Human child2 = new Human("Ульяна",false,8,c0);
Human child3 = new Human("Виктор",true,3,c0);
ArrayList<Human> c3 = new ArrayList<>();
c3.add(child1);
c3.add(child2);
c3.add(child3);
Human f1 = new Human("Сергей",true,34,c3);
Human m1 = new Human("Марина",false,32,c3);
ArrayList<Human> c4f = new ArrayList<>();
c4f.addAll(c3);
c4f.add(f1);
ArrayList<Human> c4m = new ArrayList<>();
c4m.addAll(c3);
c4m.add(m1);
Human grandf1 = new Human("Иван",true,67,c4f);
Human grandf2 = new Human("Борис",true,75,c4m);
Human grandm1 = new Human("Ирина",false,65,c4f);
Human grandm2 = new Human("Анна",false,71,c4m);
ArrayList<Human> everyone = new ArrayList<>(Arrays.asList(grandf1,grandf2,grandm1,grandm2,f1,m1,child1,child2,child3));
for(int i =0;i<everyone.size();i++){
System.out.println(everyone.get(i));
}
}
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;
}
}
}