i don't what is wrong with it
package com.codegym.task.task08.task0824;
import java.util.*;
/*
Make a family
*/
public class Solution {
public static void main(String[] args) {
ArrayList<Human> children = new ArrayList<>();
Human grandFather = new Human("Odin" , true , 835 );
Human grandFather1 = new Human("bharat" ,true , 90);
Human grandMother = new Human("Jyora" , false , 833);
Human grandMother1 = new Human("ada" , false ,234);
Human Father = new Human("thor" , true , 452 );
Human Mother = new Human("sd" , false , 234 );
Human son = new Human("Tony " , true , 23 );
Human son1 = new Human("Hulk" , true , 23 );
Human son2 = new Human("Steave" , true , 23 );
children.add(son);
children.add(son1);
children.add(son2);
children.add(Father);
children.add(Mother);
children.add(grandFather);
children.add(grandFather1);
children.add(grandMother);
children.add(grandMother1);
System.out.println(grandFather.toString());
System.out.println(grandFather1.toString());
System.out.println(grandMother.toString());
System.out.println(grandFather1.toString());
System.out.println(Father.toString());
System.out.println(Mother.toString());
System.out.println(son.toString());
System.out.println(son1.toString());
System.out.println(son2.toString());
}
public static class Human {
String name ;
boolean sex = true;
int age ;
ArrayList<Human> children = new ArrayList<>();
public Human(String name , boolean sex , int age)
{
this.name = name;
this.age = age;
this.sex = sex;
}
public Human(String name , boolean sex , int age ,ArrayList<Human> children )
{
this.name = name;
this.age = age;
this.sex = sex;
//this.Father = Father;
// this.Mother = Mother;
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;
}
}
}