package com.codegym.task.task07.task0724;

/*
Family census

*/

public class Solution {
    public static void main(String[] args) {
        // write your code here
        Human obj1 = new Human("jon", false, 23);
        Human obj2 = new Human("snow", true, 63);
        Human obj3 = new Human("donald", false, 22);
        Human obj4 = new Human("mic", true, 83);

        Human obj5 = new Human("jon", false, 23,obj1,obj2);
        Human obj6 = new Human("jon", false, 23,obj3,obj2);
        Human obj7 = new Human("jon", false, 23,obj2,obj4);
        Human obj8 = new Human("jon", false, 23,obj4,obj1);
        Human obj9 = new Human("jon", false, 23,obj4,obj3);

        System.out.println(obj1.toString());
        System.out.println(obj2.toString());
        System.out.println(obj3.toString());
        System.out.println(obj4.toString());
        System.out.println(obj5.toString());
        System.out.println(obj6.toString());
        System.out.println(obj7.toString());
        System.out.println(obj8.toString());
        System.out.println(obj9.toString());

    }

    public static class Human {
        // write your code here
        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 text = "";
            text += "Name: " + this.name;
            text += ", sex: " + (this.sex ? "male" : "female");
            text += ", age: " + this.age;

            if (this.father != null)
                text += ", father: " + this.father.name;

            if (this.mother != null)
                text += ", mother: " + this.mother.name;

            return text;
        }
    }
}