Задача: У каждой кошки есть имя и кошка-мама. Создать класс, который бы описывал данную ситуацию. Создать два объекта: кошку-дочь и кошку-маму. Вывести их на экран. Новая задача: У каждой кошки есть имя, кошка-папа и кошка-мама. Изменить класс Cat так, чтобы он мог описать данную ситуацию. Создать 6 объектов: дедушку (папин папа), бабушку (мамина мама), папу, маму, сына, дочь. Вывести их всех на экран в порядке: дедушка, бабушка, папа, мама, сын, дочь. Результат работы программы:
Cat name is дедушка Вася, no mother, no father
Cat name is бабушка Мурка, no mother, no father
Cat name is папа Котофей, no mother, father is дедушка Вася
Cat name is мама Василиса, no mother, father is бабушка Мурка
Cat name is сын Мурчик, mother is мама Василиса, father is папа Котофей
Cat name is дочь Пушинка, mother is мама Василиса, father is папа Котофей
public class Solution {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        String grandfatherName = reader.readLine();
        Cat catGrandfather = new Cat(grandfatherName);

        String grandmotherName = reader.readLine();
        Cat catGrandmother = new Cat(grandmotherName);

        String dadName = reader.readLine();
        Cat catDad = new Cat(dadName, catGrandfather);

        String motherName = reader.readLine();
        Cat catMother = new Cat(motherName, catGrandmother);

        String sonName = reader.readLine();
        Cat catSon = new Cat(sonName, catMother, catDad);

        String daughterName = reader.readLine();
        Cat catDaughter = new Cat(daughterName, catMother, catDad);

        System.out.println(catGrandfather);
        System.out.println(catGrandmother);
        System.out.println(catDad);
        System.out.println(catMother);
        System.out.println(catSon);
        System.out.println(catDaughter);}

    public static class Cat {
        private String name;
        private Cat parent, parent1;

        Cat(String name) {
           this.name = name;
        }

        Cat(String name, Cat parent) {
            this.name = name;
            this.parent = parent;
        }

        Cat(String name, Cat parent, Cat parent1) {
            this.name = name;
            this.parent = parent;
            this.parent1 = parent1;
        }

        @Override
        public String toString() {
            if (parent == null && parent1 == null)
                return "Cat name is " + name + ", no mother, no father";

            if (parent1 == null)
                return "Cat name is " + name + ", no mother, father is " + parent.name;

            if (parent == null)
                return "Cat name is " + name + ", mother is " + parent1.name + ", no father" ;

           else
                return "Cat name is " + name + ", mother is " + parent.name + ", father is " + parent1.name;
        }
    }
}