help me
package com.codegym.task.task08.task0824;
/*
Make a family
*/
import java.io.IOException;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) {
//public static void main (String[]args) throws IOException {
ArrayList<Human> c1 = new ArrayList<Human>();
// ArrayList<Human> c2 = new ArrayList<Human>();
// ArrayList<Human> c3 = new ArrayList<Human>();
Human child1 = new Human("Ronita", false, 10);
Human child2 = new Human("sad", false, 10);
Human child3 = new Human("Roa", false, 10);
c1.add(child1);
c1.add(child2);
c1.add(child3);
Human f = new Human("Raj", true, 20, c1);
Human m = new Human("Kanika", false, 20, c1);
Human gf1 = new Human("Remo", true, 40);
Human gf2 = new Human("Dharmesh", true, 10);
Human gm1 = new Human("Lina", false, 40);
Human gm2 = new Human("Tina", false, 40);
System.out.println(gf1.toString());
System.out.println(gf2.toString());
System.out.println(gm1.toString());
System.out.println(gm2.toString());
System.out.println(f.toString());
System.out.println(m.toString());
System.out.println(f.children);
//c1.forEach(System.out::println);
}
public static class Human {
//write your code here
String name;
boolean sex;
int age;
public Human(String name, boolean sex, int age) {
this.name = name;
this.sex = sex;
this.age = age;
}
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 = children;
}
public String toString() {
String text = "";
text += "Name: " + this.name;
text += ", sex: " + (this.sex ? "male" : "female");
text += ", age: " + this.age;
if (this.children != null) {
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;
}
}
}