Переменную "this" нельзя использовать в статическом контексте.
файл com/javarush/task/task06/task0621/Solution.java, строка 16, позиция 429
Подскажите плиз в чем косяк и желательно ход мыслей подкоректируйте^^(ибо не уверен что в этой задаче нужно наследовие но без него не понимаю как заставить програму понимать при введении одного значения где онли мама а где батя)
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 grFatherName = reader.readLine();
CatMale grFather = new CatMale(grFatherName);
String grMotherName = reader.readLine();
CatFemale grMother = new CatFemale(grMotherName);
String fatherName = reader.readLine();
CatMale father = new CatMale(fatherName, grFather);
String motherName = reader.readLine();
CatFemale Mother = new CatFemale(motherName,grMother);
String sonName = reader.readLine();
CatMale son = new CatMale(sonName,father,Mother);
String daughterName = reader.readLine();
Cat catDaughter = new Cat(daughterName, father,Mother);
System.out.println(catMother);
System.out.println(catDaughter);
}
public class Cat {
String name;
CatMale father;
CatFemale mom;
}
class CatMale extends Cat{
CatMale(String name) {
super.name = name;
}
CatMale(String name, Cat father) {
super.name = name;
super.father = father;
}
CatMale(String name, Cat father, Cat mom) {
super.name = name;
super.father = father;
super.mom = mom;
}
@Override
public String toString() {
if (super.mom == null && super.father == null)
return "The cat's name is " + super.name + ", no mother, "+" no father";
else if (super.mom == null)
return "The cat's name is " + super.name + ", father is " + super.father.name;
else return "The cat's name is " + super.name + ", father is " + super.father.name+" "+"mother is "+ super.mom.name;
}
}
class CatFemale extends Cat{
CatFemale(String name) {
super.name = name;
}
CatFemale(String name, Cat mom) {
super.name = name;
super.mom = mom;
}
CatFemale(String name, Cat father, Cat mom) {
super.name = name;
super.father = father;
super.mom = mom;
}
@Override
public String toString() {
if (super.mom == null && super.father == null)
return "The cat's name is " + super.name + ", no mother, "+" no father";
else if (super.father == null)
return "The cat's name is " + super.name + ", mother is " + super.mom.name;
else return "The cat's name is " + super.name + ", father is " + super.father.name+" "+", mother is "+ super.mom.name;
}
}
}