could somebody help me? what is wrong with my code?
thank you
package com.codegym.task.task08.task0824;
/*
Make a family
*/
import java.sql.SQLOutput;
import java.util.ArrayList;
import java.util.Collections;
public class Solution {
public static void main(String[] args) {
//write your code here
ArrayList<Human> childrenOlder = new ArrayList<>();
ArrayList<Human> childrenYounger = new ArrayList<>();
Human grandfather1 = new Human("Bob", true, 67, childrenOlder);
Human grandfather2 = new Human("Tom", true,77,childrenOlder );
Human grandmother1 = new Human("Susan", false,66, childrenOlder);
Human grandmother2 = new Human("Marry", false, 56, childrenOlder);
Human father = new Human("Willy", true, 40, childrenYounger);
Human mother = new Human("Balbina", false,38, childrenYounger);
Human child1 = new Human("Cathlyn", false, 12, new ArrayList<>());
Human child2 = new Human("Ben", true,13, new ArrayList<>());
Human child3 = new Human("Maja", false, 14, new ArrayList<>());
Collections.addAll(childrenYounger,child1,child2,child3);
Collections.addAll(childrenOlder,father,mother);
System.out.println(grandfather1.toString());
System.out.println(grandfather2.toString());
System.out.println(grandmother1.toString());
System.out.println(grandmother2.toString());
System.out.println(father.toString());
System.out.println(mother.toString());
System.out.println(child1.toString());
System.out.println(child2.toString());
System.out.println(child3.toString());
}
public static class Human {
//write your code here
String name;
boolean sex;
int age;
ArrayList<Human> children = new ArrayList<>();
public Human(String name, boolean sex, int age, ArrayList<Human> children) {
this.name = name;
this.sex = sex;
this.age = age;
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;
}
}
}