Не пойму почему проверку не проходит. Вроде все правильно. Чтения с клавиатуры нет.
package com.javarush.task.task07.task0724;
/*
Семейная перепись
*/
public class Solution {
public void main(String[] args) {
// напишите тут ваш код
Human grandfatherF= new Human("Василий",true,90);
Human grandmotherF= new Human("Маруся",false,80);
Human grandmotherM= new Human("Ида",false,85);
Human grandfatherM= new Human("Моисей",true,90);
Human Father = new Human("Анатолий",true,65,grandfatherF,grandmotherF);
Human mother = new Human("Раиса",false,60,grandfatherM,grandmotherM);
Human Sergey= new Human("Сергей",true,38,Father,mother);
Human Sveta= new Human("Света",false,38,Father,mother);
Human Ksenya= new Human("Ксения",false,7,Father,mother);
System.out.println(grandfatherF);
System.out.println(grandmotherF);
System.out.println(grandmotherM);
System.out.println(grandfatherM);
System.out.println(Father);
System.out.println(mother);
System.out.println(Sergey);
System.out.println(Sveta);
System.out.println(Ksenya);
}
public static class Human {
String name;
int age;
boolean sex;
Human father;
Human mother;
// напишите тут ваш код
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, Human father, Human mother)
{
this.father=father;
this.mother=mother;
this.name=name;
this.age=age;
this.sex=sex;
}
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;
}
}
}