@Override ничего не выводит
помогите пожалуйста!
package com.javarush.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 catGrandFatherName = reader.readLine();
Cat catGrandFather = new Cat(catGrandFatherName);
String catGrandmaName = reader.readLine();
Cat catGrandma = new Cat(catGrandmaName);
String catFatherName = reader.readLine();
Cat catFather = new Cat(catFatherName, null, catGrandFather);
String motherName = reader.readLine();
Cat catMother = new Cat(motherName, catGrandma, null);
String catSonName = reader.readLine();
Cat catSon = new Cat(catSonName, catMother, catFather);
String catDaughterName = reader.readLine();
Cat catDaughter = new Cat(catDaughterName, catMother, catFather);
System.out.println(catGrandFather.name);
System.out.println(catGrandma.name);
System.out.println(catFather.name);
System.out.println(catMother.name);
System.out.println(catSon.name);
System.out.println(catDaughter.name);
}
public static class Cat {
private String name;
private Cat mother;
private Cat father;
public Cat(String name) {
this.name = name;
}
public 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 "The cat's name is " + name + ", no mother no father";
else
if ((mother == null) && (father != null))
return "The cat's name is " + name + " no mother + father is " + father.name;
else
if ((mother != null) && (father == null))
return "The cat's name is " + name + "mothers name " + mother.name + " no father ";
else
return "The cat's name is " + name + "mothers name " + mother.name + " fathers name "+ father.name;
}
}
}