Подскажите, пожалуйста, все должно работать а не хочет, в чем может быть причина
package com.javarush.task.task07.task0724;
/*
Семейная перепись
*/
public class Solution {
public static void main(String[] args) {
// напишите тут ваш код
}
public static class Human {
// напишите тут ваш код
Human grandFather1 = new Human("Bob", true, 55);
Human grandFather2 = new Human("Bob2", true, 57);
Human grandMother1 = new Human("Jenifer", false, 53);
Human grandMother2 = new Human("Jenifer2", false, 51);
Human father1 = new Human("Vova", true, 40, grandFather1, grandMother1);
Human mother1 = new Human("Lena", false, 39, grandFather2, grandMother2);
Human doter1 = new Human("Eva", false, 4, father1, mother1 );
Human doter2 = new Human("Inna", false, 15, father1, mother1);
Human son = new Human("Alexandr", 17, true, father1, mother1);
System.out.println(grandFather1.toString());
grandFather2.toString();
grandMother1.toString();
grandMother2.toString();
System.out.println(father1.toString());
System.out.println(mother1.toString());
System.out.println(doter1.toString());
System.out.println(doter2.toString());
System.out.println(son.toString());
}
public static class Human {
// напишите тут ваш код
String name;
boolean sex;
int age;
Human father;
Human mother;
public Human(String name, boolean sex, int age){
this.name = name;
this.sex = sex;
this.age = 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 String toString() {
String text = "";
text += "Имя: " + this.name;
text += ", пол: " + (this.sex ? "мужской" : "женский");
text += ", возраст: " + this.age;
if (this.father != null) {
text += ", отец: " + this.father.name;
}
if (this.mother != null) {
text += ", мать: " + this.mother.name;
}
return text;
}
}
}