Why it cant fit the conditions?
Help please
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 grandfatherName = reader.readLine();
Cat grandfather = new Cat(grandfatherName);
String grandmontherName = reader.readLine();
Cat grandmonther = new Cat(grandmontherName);
String fatherName = reader.readLine();
Cat father = new Cat(fatherName,grandfather);
String montherName = reader.readLine();
Cat monther = new Cat(montherName,grandmonther);
String sonName = reader.readLine();
Cat son = new Cat(sonName,father,monther);
String daughterName = reader.readLine();
Cat daughter = new Cat(daughterName,father,monther);
System.out.println(grandfather.toString());
System.out.println(grandmonther.toString());
System.out.println(father.toString());
System.out.println(monther.toString());
System.out.println(son.toString());
System.out.println(daughter.toString());
// String daughterName = reader.readLine();
// Cat catDaughter = new Cat(daughterName, catMother);
// System.out.println(catMother);
// System.out.println(catDaughter);
}
public static class Cat {
private String name;
private Cat parent1;
private Cat parent2;
private Cat father;
private Cat monther;
Cat(String name) {
this.name = name;
}
Cat(String name, Cat parent1) {
this.name = name;
this.parent1 = parent1;
}
// Cat(String name, Cat parent2) {
// this.name = name;
// this.parent2 = parent2;
// }
Cat(String name,Cat father,Cat monther){
this.name =name;
this.father=father;
this.monther=monther;
}
// Cat(String name, Cat father){
// this.name = name;
// this.father = father;
// }
@Override
public String toString() {
if (parent1 == null&&parent2 ==null&&father==null&&monther==null)
return "The cat's name is " + name + ", no mother, no father ";
else if(parent1!=null&&parent1.name.equals("Grandfather Tiger"))
return "The cat's name is " + name + ", no mother, " + parent1.name + " is the father";
else if(parent1!=null&&parent1.name.equals("Grandmother Puss"))
return "The cat's name is " + name+ ", "+ parent1.name + " is the mother, no father";
else
//(father != null && monther !=null)
return "The cat's name is " + name + ", "+monther.name+" is the mother, "+father.name+" is the father";
}
}
}