package com.javarush.task.task07.task0724;

/*
Семейная перепись
*/

public class Solution {
    public static void main(String[] args) {


        for (int i = 0; i < 4; i++)
            Human human1 = new Human("Sirota", true , 1);
            System.out.println(human1);

        for (int i = 0; i < 5; i++)
            Human human2 = new Human("Semjanin", true , 1, new Human(), new Human());
            System.out.println(human2);


    }

    public static class Human {

        String name = null;
        boolean sex  ;
        int age = 0;
        Human mother ;
        Human father ;


        public Human() {

        }

        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;
        }
    }
}