public class Solution {
public static void main(String[] args) {
Human grandFatherK = new Human("Кирил", true, 68);
Human grandMotherK = new Human("Карина", false,60);
Human grandFatherS = new Human("Санек", true, 65);
Human grandMotherS = new Human("Света", true, 60);
Human father = new Human("Витя", true, 32,grandFatherK, grandMotherK);
Human mother = new Human("Оксана", false, 28, grandFatherS, grandMotherS);
Human baby1 = new Human("Богдан", true, 13,father,mother);
Human baby2 = new Human("Вика", false, 8,father,mother);
Human baby3 = new Human("Катя", false, 5,father,mother);
}
public static class Human {
//напишите тут ваш код
String name ;
boolean sex;
int age;
Human father = new Human(name, sex, age);
Human mother = new Human(name, sex, age);
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;
}
}
}
package com.javarush.task.task07.task0724;
/*
Семейная перепись
*/
public class Solution {
public static void main(String[] args) {
Human grandFatherK = new Human("Кирил", true, 68);
Human grandMotherK = new Human("Карина", false,60);
Human grandFatherS = new Human("Санек", true, 65);
Human grandMotherS = new Human("Света", true, 60);
Human father = new Human("Витя", true, 32,grandFatherK, grandMotherK);
Human mother = new Human("Оксана", false, 28, grandFatherS, grandMotherS);
Human baby1 = new Human("Богдан", true, 13,father,mother);
Human baby2 = new Human("Вика", false, 8,father,mother);
Human baby3 = new Human("Катя", false, 5,father,mother);
}
public static class Human {
//напишите тут ваш код
String name ;
boolean sex;
int age;
Human father = new Human(name, sex, age);
Human mother = new Human(name, sex, age);
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;
}
}
}