what's wrong?
package com.codegym.task.task08.task0824;
/*
Make a family
*/
import java.util.*;
public class Solution {
public static void main(String[] args) {
ArrayList <Human> children=new ArrayList<>();
Human son=new Human("Vasia",true,15,new ArrayList<Human>());
Human son1=new Human("Petia", true, 10,new ArrayList<Human>());
Human daughter=new Human("Lily",false,7,new ArrayList<Human>());
children.add(son); children.add(son1); children.add(daughter);
ArrayList <Human> parent1=new ArrayList<>();
Human dad=new Human("Petr",true,50,children);
parent1.add(dad);
ArrayList <Human> parent2=new ArrayList<>();
Human mom=new Human("Zina",false,47,children);
parent2.add(mom);
Human grandpa= new Human("Alex",true, 85,parent1);
Human grandma= new Human("Nura",false,84,parent1);
Human grandpa1=new Human("Serg",true, 80,parent2);
Human grandma1=new Human("Lilu",false,80,parent2);
ArrayList<Human> family=new ArrayList<>();
family.add(son);
family.add(son1);
family.add(daughter);
family.add(dad);
family.add(mom);
family.add(grandpa);
family.add(grandpa1);
family.add(grandma);
family.add(grandma1);
//write your here
System.out.println(family.toString());
}
public static class Human {
public String name;
public boolean sex;
public int age;
public 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=new ArrayList<>();
}
public Human (String name,boolean sex,int age) {
this.name=name;
this.sex=sex;
this.age=age;
}
//write your code here
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 += ", children: " + this.children.get(0).name;
for (int i = 1; i < childCount; i++) {
Human child = this.children.get(i);
text += ", " + child.name;
}
}
return text;
}
}
}