can't satisfy the fourth condition onwards
package com.codegym.task.task06.task0621;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Cat relations
*/
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String grandDad= reader.readLine();
Cat grandDad1 = new Cat("Tiger");
String grandMum= reader.readLine();
Cat grandMum1 = new Cat("Puss");
String dad = reader.readLine();
Cat dad1 = new Cat("Oscar",null,grandDad1);
String mom = reader.readLine();
Cat mom1 = new Cat("Missy",grandMum1,null);
String son = reader.readLine();
Cat son1 = new Cat("Simba",mom1,dad1);
String daughter = reader.readLine();
Cat daughter1 = new Cat("Coco",mom1,dad1);
System.out.println(grandDad1);
System.out.println(grandMum1);
System.out.println(dad1);
System.out.println(mom1);
System.out.println(son1);
System.out.println(daughter1);
}
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;
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)
return "The cat's name is " + name + ", no mother, "+ father.name+" is the father";
else if (father==null)
return "The cat's name is " + name + ", " + mother.name + " is the mother, no father";
else return "The cat's name is " + name + ", " + mother.name + " is the mother, " + father.name+ " is the father";
}
}
}