ΠΏΠΎΡΠ΅ΠΌΡ Π½Π΅ Π΄ΠΎΠ±Π°Π²Π»ΡΡΡ ΠΎΠ±Π΅ΠΊΡ Π² ΠΌΠ°ΡΠΈΠ²?
package com.javarush.task.task08.task0824;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/*
Π‘ΠΎΠ±ΠΈΡΠ°Π΅ΠΌ ΡΠ΅ΠΌΠ΅ΠΉΡΡΠ²ΠΎ
*/
public class Solution {
public static void main(String[] args) {
//Π½Π°ΠΏΠΈΡΠΈΡΠ΅ ΡΡΡ Π²Π°Ρ ΠΊΠΎΠ΄
}
public static class Human {
//Π½Π°ΠΏΠΈΡΠΈΡΠ΅ ΡΡΡ Π²Π°Ρ ΠΊΠΎΠ΄
String name;
boolean sex;
int age;
ArrayList<Human> children = new ArrayList<>();
Human grendfather = new Human();
Human grendfather2 = new Human();
Human grendmather = new Human();
Human grendmather2 = new Human();
Human father = new Human();
Human mather = new Human();
Human child1 = new Human();
Human child2 = new Human();
Human child3 = new Human();
children.add(child1);
children.add(child2);
children.add(child3);
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;
}
}
}