package com.javarush.task.jdk13.task07.task0724;
/*
Семья
*/
public class Solution {
public static void main(String[] args) {
Human gf1 = new Human("Миша", true, 60);
Human gm1 = new Human("Лена", false, 61);
Human gf2 = new Human("Игорь", true, 62);
Human gm2 = new Human("Лариса", false, 63);
Human dad = new Human("Саша", true, 41, gf1, gm1);
Human mom = new Human("Галя", false, 31, gf2, gm2);
Human ch1 = new Human("Аня", false, 10, dad, mom);
Human ch2 = new Human("Катя", false, 11, dad, mom);
Human ch3 = new Human("Никита", true, 12, dad, mom);
System.out.println(gf1);
System.out.println(gm2);
System.out.println(gf2);
System.out.println(gm2);
System.out.println(dad);
System.out.println(mom);
System.out.println(ch1);
System.out.println(ch2);
System.out.println(ch3);
}
public static class Human {
private String name;
private boolean sex;
private int age;
private Human father;
private Human mother;
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 += "Имя: " + 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;
}
}
}
Никита Володин
22 уровень
Программа правильная, но не проходит последнее условие валидатора. В чем может быть проблема?
Решен
Комментарии (3)
- популярные
- новые
- старые
Для того, чтобы оставить комментарий Вы должны авторизоваться
Никита Володинdatabase developer в Ингосстрах-М
24 сентября 2022, 16:14
Спасибо за помощь!
0
Амиров СтаниславМастер участка механическ в ООО "Новомосковск-Ре
24 сентября 2022, 14:58
Вывод на экран двоится в 21 строке.
+1
Олег Пономарев
24 сентября 2022, 14:33
Внимательно посмотрите что выводите, найдете ошибку
+2