import java.util.ArrayList; public class Solution { public static void main(String[] args) { // напишите тут ваш код Human grandPap1 = new Human("Bob",true,72,null,null); Human grandPap2 = new Human("Jim",true,69,null,null); Human grandMam1 = new Human("Grace",false,70,null,null); Human grandMam2 = new Human("Bonny",false,65,null,null); Human father = new Human("Tom",true,45,grandPap1,grandMam1); Human mother = new Human("Julia",false,42,grandPap2,grandMam2); Human son1 = new Human("Jonny",true,19,father,mother); Human son2 = new Human("Billy",true,16,father,mother); Human daugther = new Human("Sanny",false,12,father,mother); ArrayList<Human> list = new ArrayList<>(); list.add(grandPap1); list.add(grandPap2); list.add(grandMam1); list.add(grandMam2); list.add(father); list.add(mother); list.add(son1); list.add(son2); list.add(daugther); for(int i = 0; i < list.size(); i++){ System.out.println(list.get(i)); } } public static class Human { // напишите тут ваш код String name; boolean sex; int age; Human father; 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; System.out.println(toString()); } 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; } } }