Программа выдаёт ошибку при переходе на 19 строку.
Cat catDaughter = new Cat(daughterName, catMother);
Помогите разобраться, в чём проблема.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 dedName = reader.readLine();
Cat dedCat = new Cat(dedName);
String babName = reader.readLine();
Cat babCat = new Cat(babName);
String fatherName = reader.readLine();
Cat catFather = new Cat(fatherName, dedCat);
String motherName = reader.readLine();
Cat catMother = new Cat(motherName, babCat);
String sonName = reader.readLine();
Cat sonCat = new Cat(sonName, catFather);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, catMother);
System.out.println(dedCat);
System.out.println(babCat);
System.out.println(catFather);
System.out.println(catMother);
System.out.println(sonCat);
System.out.println(daughterName);
}
public static class Cat {
private String name;
private Cat father;
private Cat mother;
@Override
Cat(String name, Cat mother){
this.name = name;
this.mother = mother;
}
@Override
Cat(String name, Cat father){
this.name = name;
this.father = father;
}
@Override
Cat(String name) {
this.name = name;
}
@Override
Cat(String name, Cat father, Cat mother) {
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 + ", father is " + father.name+ ", no mother";
else if (mother != null && father == null )
return "The cat's name is " + name + ", no father " + ", mother is " + mother.name;
else return "The cat's name is " + name + ", father is " + father.name+ ", mother is " + mother.name;
}
}
}