В IDE код работает, но валидацию не проходит. В чем секрет? Подскажите пожалуйста!!!
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();
// String grandFatherName = "дедушка Вася";
Cat catGrandFather = new Cat(grandFatherName);
String grandMotherName = reader.readLine();
// String grandMotherName = "бабушка Мурка";
Cat catGrandMother = new Cat(grandMotherName);
String fatherName = reader.readLine();
// String fatherName = "папа Котофей";
Cat catFather = new Cat(fatherName, catGrandFather);
String motherName = reader.readLine();
// String motherName = "мама Василиса";
Cat catMother = new Cat(motherName, catGrandMother);
String sonName = reader.readLine();
// String sonName = "сын Мурчик";
Cat catSon = new Cat(sonName, catFather , catMother);
String daughterName = reader.readLine();
// String daughterName = "дочь Пушинка";
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(catDaughter);
System.out.println(catSon);
}
public static class Cat {
private static int catcount = 0;
private int catnum;
private String name;
private Cat mother;
private Cat father;
private Cat grabdfather;
private Cat grandmother;
private Cat son;
private Cat daughter;
Cat(String name) {
this.name = name;
catcount++;
this.catnum = catcount;
}
Cat(String name, Cat grabdfather) {
switch (catcount){
case 2:
this.name = name;
this.father = grabdfather;
this.mother = null;
break;
case 3:
this.name = name;
this.father = null;
this.mother = grabdfather;
break;
}
catcount++;
}
Cat(String name, Cat p1, Cat p2) {
this.name = name;
this.father = p1;
this.mother = p2;
}
@Override
public String toString() {
if (mother == null && father != null)
return "Cat name is " + name + ", no mother, father is " + father.name;
else if (mother != null && father == null)
return "Cat name is " + name + ", mother is " + mother.name + ", no father";
else if (catnum == 1)
return "Cat name is " + name + ", no mother, no father";
else if (catnum == 2)
return "Cat name is " + name + ", no mother, no father";
else if (catcount == 3)
return "Cat name is " + father.name + ", no mother, father is " + grabdfather.name;
else
return "Cat name is " + name + ", mother is " + mother.name + ", father is " + father.name;
}
}
}