подскажите
package com.javarush.task.task06.task0621;
import java.util.Scanner;
/*
Родственные связи кошек
*/
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String grandpaName = in.nextLine();
Cat catGrandpa = new Cat(grandpaName);
String grandmaName = in.nextLine();
Cat catGrandma = new Cat(grandmaName);
String fatherName = in.nextLine();
Cat catFather = new Cat(fatherName, catGrandma, catGrandpa);
String motherName = in.nextLine();
Cat catMother = new Cat(motherName, catGrandma, catGrandpa);
String sonName = in.nextLine();
Cat catSon = new Cat(sonName, catMother, catFather);
String daughterName = in.nextLine();
Cat catDaughter = new Cat(daughterName, catMother, catFather);
System.out.println(catGrandpa);
System.out.println(catGrandma);
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 father;
private Cat mother;
Cat(String name) {
this.name = name;
}
Cat(String name, Cat father, Cat mother) {
this.name = name;
this.father = father;
this.mother = mother;
}
public String toString() {
if (father == null && mother == null)
return "The cat's name is " + name + ", no mother, no father ";
if (mother == null)
return "The cat's name is " + name + ", no mother, father is " + father.name;
}
}
}