Вроде как всё окей, но валидатор ругается.
В чём проблема?
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 GrandfatherName = reader.readLine();
Cat catGrandfather = new Cat(GrandfatherName, null, null);
String GrandmotherName = reader.readLine();
Cat catGrandmother = new Cat(GrandmotherName, null, null);
String FatherName = reader.readLine();
Cat catFather = new Cat(FatherName, catGrandfather, catGrandmother);
String MotherName = reader.readLine();
Cat catMother = new Cat(MotherName, catGranfather, catGrandmother);
String sunName = reader.readLine();
Cat catSun = new Cat(sunName, catFather, catMother);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, catFather, catMother);
System.out.println(catGrandfather);
System.out.println(catGrandmother);
System.out.println(catFather);
System.out.println(catMother);
System.out.println(catSun);
System.out.println(catDaughter);
}
public static class Cat {
private String name;
private Cat parentFather;
private Cat parentMother;
Cat(String name, Cat parentFather, Cat parentMother) {
this.name = name;
this.parentFather = parentFather;
this.parentMother = parentMother;
}
@Override
public String toString() {
if (parentFather == null && parentMother == null)
return "The cat's name is " + name + ", no mother, " + "no father";
else if (parentMother == null)
return "The cat's name is " + name + ", no mother, " + "father is" + parentFather.name;
else if (parentFather == null)
return "The cat's name is " + name + ", mother is " + parentFather.name + "no father";
else
return "The cat's name is " + name + ", mother is " + parentMother.name + ", father is" + parentFather.name;
}
}
}