Помогите
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
Human sohn1 = new Human("Serega",true,30);
Human sohn2 = new Human("Valera",true,20);
Human sohn3 = new Human("Max",true,10);
ArrayList<Human> children = new ArrayList<Human>();
children.add(sohn1);
children.add(sohn2);
children.add(sohn3);
Human father = new Human("Batya",true,50,children);
Human mather = new Human("Mutter",false,50,children);
ArrayList<Human> children2 = new ArrayList<Human>();
children2.add(father);
children2.add(mather);
Human grandfather1 = new Human("ded1",true,50,children2);
Human grandfather2 = new Human("ded2",true,55,children2);
Human grandmather1 = new Human("baba1",false,60,children2);
Human grandmather2 = new Human("baba2",false,70,children2);
System.out.println(grandfather1);
System.out.println(grandfather2);
System.out.println(grandmather1);
System.out.println(grandmather2);
System.out.println(father);
System.out.println(mather);
System.out.println(sohn1);
System.out.println(sohn2);
System.out.println(sohn3);
}
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 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;
}
}
}