Помогите....
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 catDed = new Cat(dedName,null, null);
String babName = reader.readLine();
Cat catBab = new Cat(babName, null, null);
String fatherName = reader.readLine();
Cat catFather = new Cat(fatherName, null, catDed);
String motherName = reader.readLine();
Cat catMother = new Cat(motherName, catBab, null);
String sonName = reader.readLine();
Cat catSon = new Cat(sonName, catMother, catFather);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, catMother, catFather);
System.out.println(catDed);
System.out.println(catBab);
System.out.println(catFather);
System.out.println(catMother);
System.out.println(catSon);
System.out.println(catDaughter);
}
public static class Cat {
private String name;
private Cat pa;
private Cat ma;
// Cat(String name) {
// this.name = name;
// }
Cat(String name, Cat pa, Cat ma) {
this.name = name;
this.pa = pa;
this.ma = ma;
}
@Override
public String toString() {
if (pa == null && ma == null)
return "The cat's name is " + name + ", no mother, no father";
else
if (pa == null && ma!=null)
return "The cat's name is " + name + ", mother is " + ma + ", no father";
else
if (ma == null && pa!=null)
return "The cat's name is " + name + ", no mother, father is " + pa;
else
if (ma!= null && pa!= null)
return "The cat's name is " + name + ", mother is " + ma + ", father is" + pa;
else return null;
}
}
}