Доброго времени суток, прошу подсказать какие у меня ошибки в коде.
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.List;
/*
Собираем семейство
*/
public class Solution {
public static void main(String[] args) {
//напишите тут ваш код
Human grandDaddy1= new Human("Igor",true,89,null);
Human grandDaddy2= new Human("Vova",true,98,null);
Human granny1= new Human("Vala",false,89,null);
Human granny2= new Human("Val",false,98,null);
Human daddy= new Human("Viktor",true,39,null);
Human mom= new Human("Vala",false,89,null);
Human child1 = new Human("Lena",false,15,new ArrayList<>());
Human child2 = new Human("Len",false,15,new ArrayList<>());
Human child3 = new Human("Le",false,15,new ArrayList<>());
System.out.println(grandDaddy1.toString());
System.out.println(grandDaddy2.toString());
System.out.println(granny1.toString());
System.out.println(granny2.toString());
System.out.println(daddy.toString());
System.out.println(mom.toString());
System.out.println(child1.toString());
System.out.println(child2.toString());
System.out.println(child3.toString());
}
public static class Human {
//напишите тут ваш код
String name;
boolean sex;
int age;
ArrayList<Human>children;
public Human (String name, boolean sex, int age, ArrayList<Human>children) {
this.name = name;
this.sex = sex;
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;
}
}
}