Снова спотыкаюсь об синтаксис
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human grandPa = new Human("дедушка", true, 99, );
Human grandPa2 = new Human("дедушка2", true, 100, );
Human grandMa = new Human("бабушка", false, 89, );
Human grandMa2 = new Human("бабушка2", false, 90, )
Human father = new Human("папа", true, 50, children1, children2, children3);
Human mother = new Human("мама", false, 46, );
Human children1 = new Human("дочь", false, 24);
Human children2 = new Human("сын", true, 22);
Human children3 = new Human("сын", true, 14);
}
public static class Human {
//напишите тут ваш код
String name;
boolean isMan;
int age;
ArrayList<Human> children;
public Human(String name, boolean isMan, int age){
this.name = name;
this.isMan = isMan;
this.age = age;
}
public Human(String name, boolean isMan, int age, ArrayList<Human> children){
this.name = name;
this.isMan = isMan;
this.age = age;
this.children = children;
}
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;
}
}
}