Какого retiurn не хватает?
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 grandpa = reader.readLine();
Cat catgrandpa = new Cat(grandpa);
String grandma = reader.readLine();
Cat catgrandma = new Cat(grandma);
String papa = reader.readLine();
Cat catpapa = new Cat(papa, null, catgrandpa);
String mama = reader.readLine();
Cat catmama = new Cat(mama, catgrandma, null);
String son = reader.readLine();
Cat catson = new Cat(son,catmama, catpapa);
String dot = reader.readLine();
Cat catdot = new Cat(dot, catmama, catpapa);
System.out.println(catgrandpa);
System.out.println(catgrandma);
System.out.println(catpapa);
System.out.println(catmama);
System.out.println(catson);
System.out.println(catdot);
}
public static class Cat {
private String name;
private Cat father;
private Cat mother;
Cat(String name) {
this.name = name;
}
Cat(String name, Cat mother, Cat father) {
this.name = name;
this.mother = mother;
}
@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 + " mother is " + mother.name + ", no father";}
else if (mother == null && father == null){
return "The cat's name is " + name + " mother is " + mother.name + ", father is " + father.name;
}
}
}
}