Помогите пожалуйста.
package com.javarush.task.task08.task0824;
/*
Собираем семейство
*/
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) {
Human child1 = new Human("Baby1", true, 5);
Human child2 = new Human("Baby2", true, 4);
Human child3 = new Human("Baby3", false, 3);
Human father = new Human("Dad", true, 26, child1, child2, child3);
Human mother = new Human("Mom", false, 25, child1, child2, child3);
Human grandfather1 = new Human("Grandfather1", true, 51);
Human grandfather2 = new Human("Grandfather2", true, 52);
Human grandmother1 = new Human("Granny1", false, 54);
Human grandmother2 = new Human("Granny2", false, 55);
System.out.println(child1.toString());
System.out.println(child2.toString());
System.out.println(child3.toString());
System.out.println(father.toString());
System.out.println(mother.toString());
System.out.println(grandfather1.toString());
System.out.println(grandfather2.toString());
System.out.println(grandmother1.toString());
System.out.println(grandmother2.toString());
}
public static class Human {
public String name;
public int age;
public boolean sex;
public ArrayList<Human> children = new ArrayList<>();
public Human(String name, boolean sex, int age) {
super();
this.name = name;
this.age = age;
this.sex = sex;
}
public Human(String name, boolean sex, int age, Human children) {
super();
this.name = name;
this.age = age;
this.sex = sex;
this.children.add(children);
}
public Human(String name, boolean sex, int age, Human baby1, Human baby2, Human baby3) {
super();
this.name = name;
this.age = age;
this.sex = sex;
this.children.add(baby1);
this.children.add(baby2);
this.children.add(baby3);
}
public String toString() {
String text = "";
text += "Name: " + this.name;
text += ", sex: " + (this.sex ? "male" : "female");
text += ", age: " + this.age;
int childCount = this.children.size();
if (childCount > 0) {
text += ", childrens: " + this.children.get(0).name;
for (int i = 1; i < childCount; i++) {
Human child = this.children.get(i);
text += ", " + child.name;
}
}
return text;
}
}
}