help me!
package com.codegym.task.task07.task0724;
/*
Family census
*/
public class Solution {
public static void main(String[] args) {
Human h1 = new Human("s", true, 1);
Human h2 = new Human("s", true, 1);
Human h3 = new Human("s", true, 1);
Human h4 = new Human("s", true, 1);
Human h5 = new Human("s", true, 1, grandfather2, grandmother2);
Human h6 = new Human("s", true, 1, grandfather1, grandmother1);
Human h7 = new Human("s", true, 1, father, mother);
Human h8 = new Human("s", true, 1, father, mother);
Human h9 = new Human("s", true, 1, father, mother);
System.out.println(h1);
}
public static class Human {
String name;
Human father;
Human mother;
boolean sex;
int age;
public Human(String name, boolean sex, int age, Human father, Human mother){
this.name = name;
this.sex = sex;
this.age = age;
this.father = father;
this.mother = mother;
}
public Human(String name, boolean sex, int age){
this.name = name;
this.sex = sex;
this.age = age;
}
public String toString() {
String text = "";
text += "Name: " + this.name;
text += ", sex: " + (this.sex ? "male" : "female");
text += ", age: " + this.age;
if (this.father != null)
text += ", father: " + this.father.name;
if (this.mother != null)
text += ", mother: " + this.mother.name;
return text;
}
}
}