в чем-то проблема
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human son = new Human("Riha",true,7,null);
Human son1 = new Human("Leo",true,8,null);
Human daughter = new Human("Donatella",false,9,null);
ArrayList<Human> list = new ArrayList<Human>();
list.add(son);
list.add(son1);
list.add(daughter);
Human m = new Human("Hailey", false , 27, son, son1, daughter);
Human f = new Human("Justin", true ,34, son, son1, daughter);
ArrayList<Human> jelby = new ArrayList<Human>();
jelby.add(m);
jelby.add(f);
Human gm = new Human("Gracy",false,67,list1);
Human gf = new Human("Zayn",true,72,list1);
Human gm1 = new Human("Emma",false,71,list2);
Human gf1 = new Human("Noah",true,75,list2);
System.out.println(son.toString());
System.out.println(son1.toString());
System.out.println(daughter.toString());
System.out.println(m.toString());
System.out.println(f.toString());
System.out.println(gm.toString());
System.out.println(gf.toString());
System.out.println(gm1.toString());
System.out.println(gf1.toString());
}
public static class Human {
//напишите тут ваш код
String name;
boolean sex;
int age;
ArrayList<Human> children = new ArrayList<Human>();
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;
}
}
}