почему не работает?
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
}
public static class Human {
String name;
int age = 0;
Boolean sex;
ArrayList<Human> children = new ArrayList<>();
public Human (String name,int age, Boolean sex, Human human){
this.name = name;
this.age = age;
this.sex = sex;
children.add(human);
}
public Human (String name,int age, Boolean sex){
this.name = name;
this.age = age;
this.sex = sex;
}
Human child1 = new Human("Petr",12,true);
Human child2 = new Human("Pet",15,true);
Human child3 = new Human("Pina",14,false);
Human mother = new Human("helena", 32, false);
mother.children.add(child1);
mother.children.add(child2);
mother.children.add(child3);
Human father = new Human("bred",33.true);
father.children.add(child1);
father.children.add(child2);
father.children.add(child3);
Human grandnather1 = new Human ("dasha",54,false);
grandnather1.children.add(mother);
Human grandfather1 = new Human ("dima",55,true);
grandfather1.children.add(mother);
Human grandmather2 = new Human("kat",66,false);
grandmather2.children.add(father);
Human grandfather2 = new Human ("dima",55,true);
grandfather2.children.add(mother);
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;
}
}
}