com.javarush.task.task07.task0724.Solution$Human@7a30d1e6
com.javarush.task.task07.task0724.Solution$Human@5891e32e
com.javarush.task.task07.task0724.Solution$Human@cb0ed20
com.javarush.task.task07.task0724.Solution$Human@8e24743
com.javarush.task.task07.task0724.Solution$Human@74a10858
com.javarush.task.task07.task0724.Solution$Human@23fe1d71
com.javarush.task.task07.task0724.Solution$Human@28ac3dc3
com.javarush.task.task07.task0724.Solution$Human@32eebfca
com.javarush.task.task07.task0724.Solution$Human@4e718207
package com.javarush.task.task07.task0724;
/*
Семейная перепись
*/
public class Solution {
public static void main(String[] args) {
// напишите тут ваш код
Human h1 = new Human("Аня", true, 21);
Human h2 = new Human("Катя", true, 55);
Human h3 = new Human("Игорь", false, 2);
Human h4 = new Human("Петя", false, 24);
Human h5 = new Human("Петя", false, 24, h1, h3);
Human h6 = new Human("Петя", false, 24, h1, h3);
Human h7 = new Human("Петя", false, 24, h1, h3);
Human h8 = new Human("Петя", false, 24, h1, h3);
Human h9 = new Human("Петя", false, 24, h1, h3);
System.out.println(h1.toString());
System.out.println(h2.toString());
System.out.println(h3.toString());
System.out.println(h4.toString());
System.out.println(h5.toString());
System.out.println(h6.toString());
System.out.println(h7.toString());
System.out.println(h8.toString());
System.out.println(h9.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 name, boolean sex, int age, Human father, Human mother) {
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;
}
}
}