I can't find the problem, please help.
package com.codegym.task.task08.task0824;
/*
Make a family
*/
public class Solution {
public static void main(String[] args) {
//write your code here
ArrayList<Human> grandparentsA = new ArrayList<>();
ArrayList<Human> grandparentsB = new ArrayList<>();
ArrayList<Human> parents = new ArrayList<>();
ArrayList<Human> children = new ArrayList<>();
Human grandfatherA = new Human("John", true, 70, grandparentsA);
Human grandmotherA = new Human("Jane", false, 70, grandparentsA);
Human grandfatherB = new Human("John", true, 70, grandparentsB);
Human grandmotherB = new Human("Jane", false, 70, grandparentsB);
Human father =new Human("Jim", true, 50, parents);
grandparentsA.add(father);
Human mother = new Human("Mary", false, 50, parents);
grandparentsB.add(mother);
Human sonA = new Human("Tim", 10, true, children);
Human sonB = new Human("Tom", 9, true, children);
Human sonC = new Human("Bob", 8, true, children);
Collections.addAll(parents, sonA, sonB, sonC);
System.out.println(grandfatherA);
System.out.println(grandmotherA);
System.out.println(grandfatherB);
System.out.println(grandmotherB);
System.out.println(father);
System.out.println(mother);
System.out.println(sonA);
System.out.println(sonB);
System.out.println(sonC);
}
public static class Human {
//write your code here
public String name;
public boolean sex;
public int age;
ArrayList<Human> children = new ArrayList<>();
public Human(String name, int age, boolean sex, ArrayList<Human> children){
this.name = name;
this.age = age;
this.sex = sex;
this.children = children;
}
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;
}
}
}