первый раз не могу понять что они хотят
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human gr = new Human("Vasil", true, 60);
Human gr2 = new Human("Serhij", true, 55);
Human grm = new Human("Marija", false, 50);
Human grm2 = new Human("Sofia", false, 55);
Human dad = new Human("Henry", true, 30);
Human mom = new Human("Mery", false, 28);
Human ch = new Human("A", true, 3);
Human ch2 = new Human("B", false, 5);
Human ch3 = new Human("C", true, 13);
ArrayList<Human> children = new ArrayList<>();
children.add(ch);
children.add(ch2);
children.add(ch3);
System.out.println(gr.toString());
System.out.println(gr2.toString());
System.out.println(grm.toString());
System.out.println(grm2.toString());
System.out.println(dad.toString());
System.out.println(mom.toString());
System.out.println(ch.toString());
System.out.println(ch2.toString());
System.out.println(ch3.toString());
}
public static class Human {
String name;
boolean sex;
int age;
ArrayList<Human> children;
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;
int childCount = this.children.size();
if (childCount > 0) {
text += ", дети: " + this.children.get(0).name;
for (int i = 1; i < childCount; i++) {
Human child = this.children.get(i);
text += ", " + child.name;
}
}
return text;
}
}
}