Отсутствует индикатор или переменная в строке с принтлн.
package com.javarush.task.task07.task0724;
/*
Семейная перепись
*/
public class Solution {
public static void main(String[] args) {
// напишите тут ваш код
}
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;
}
Human vasya = new Human("Vasya", true, 40);
Human petya = new Human("Petya", true, 50);
Human katya = new Human("Katya", false, 30);
Human alla = new Human("Alla", false, 20);
Human sasha = new Human("Sasha",true, 10, vasya, alla);
Human lena = new Human("Lena",false, 11, vasya, katya);
Human dima = new Human("Dima",true, 5, vasya, alla);
Human goga = new Human("Goga",true, 1, vasya, alla);
Human mira = new Human("Mira",false, 3, vasya, alla);
System.out.println(vasya.toString());
System.out.println(petya.toString());
System.out.println(katya.toString());
System.out.println(alla.toString());
System.out.println(sasha.toString());
System.out.println(lena.toString());
System.out.println(dima.toString());
System.out.println(goga.toString());
System.out.println(mira.toString());
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;
}
}
}