1
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));
int notMother = 1;
int notFather = 2;
String grandFather = reader.readLine();
Cat catGrandFather = new Cat(grandFather, notMother, notFather);
String grandMother = reader.readLine();
Cat catGrandMother = new Cat(grandMother, notMother, notFather);
String fatherName = reader.readLine();
Cat catFather = new Cat(fatherName, notMother, grandFather);
String motherName = reader.readLine();
Cat catMother = new Cat(motherName, motherName, notFather);
String sonName = reader.readLine();
Cat catSon = new Cat(sonName, motherName, fatherName);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, motherName, fatherName);
System.out.println(catGrandFather);
System.out.println(catGrandMother);
System.out.println(catFather);
System.out.println(catMother);
System.out.println(catSon);
System.out.println(catDaughter);
}
public static class Cat {
private String name;
private int noneMother;
private int noneFather;
private String father;
private String mother;
private String grandFather;
private String grandMother;
Cat(String name) {
this.name = name;
}
Cat(String name, int noneMother, int noneFather) {
this.name = name;
this.noneMother = noneMother;
this.noneFather = noneFather;
}
Cat(String name, String mother, String father) {
this.name = name;
this.mother = mother;
this.father = father;
}
Cat(String name, int noneMother, String grandFather) {
this.name = name;
this.noneMother = noneMother;
this.grandFather = grandFather;
}
Cat(String name, String grandMother, int noneFather) {
this.name = name;
this.grandMother = grandMother;
this.noneFather = noneFather;
}
@Override
public String toString() {
if (noneMother == 1 && noneFather == 2) {
return "The cat's name is " + name + ", no mother, no father ";
} else if (noneMother == 1 && noneFather != 2) {
return "The cat's name is " + name + ", no mother, father is " + grandFather;
} else if (noneMother != 1 && noneFather == 2) {
return "The cat's name is " + name + " , mother is " + grandMother + ", no father ";
} else {
return "The cat's name is " + name + ", mother is "+ mother + " , father is " + father ;
}
}
}
}