package zh.codegym.task.task06.task0621;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
猫之间的关系
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String grandfather=reader.readLine();
Cat catgreadfather = new Cat(grandfather);
String grandmother = reader.readLine();
Cat catgrandmother = new Cat(grandmother);
String father = reader.readLine();
Cat catfather = new Cat(father,null,catgreadfather);
String motherName = reader.readLine();
Cat catMother = new Cat(motherName,catgrandmother,null);
String son= reader.readLine();
Cat catson = new Cat(son,catMother,catfather);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, catMother,catfather);
System.out.println(catgreadfather);
System.out.println(catgrandmother);
System.out.println(catfather);
System.out.println(catMother);
System.out.println(catson);
System.out.println(catDaughter);
}
public static class Cat {
private String name;
private Cat Mother;
private Cat Father;
Cat(String name) {
this.name = name;
}
Cat(String name, Cat Mother ) {
this.name = name;
this.Mother = Mother;
}
Cat(String name,Cat Mother,Cat Father)
{
this.name=name;
this.Mother=Mother;
this.Father=Father;
}
@Override
public String toString() {
if (Mother == null && Father == null)
return "猫的名字为" + name + ",无母亲,无父亲";
else if (Mother == null)
return "猫的名字为" + name + ",无母亲," + Father.name + "是父亲";
else if (Father == null)
return "猫的名字为" + name + "," + Mother.name + "是母亲,无父亲";
else
return "猫的名字为" + name + ", " + Mother.name + "是母亲," + Father.name + " 是父亲";
}
}
}