Почему валидатор не признает Hen абстрактным ?!
package com.javarush.task.task14.task1408;
/*
Куриная фабрика
*/
public class Solution {
public static void main(String[] args) {
Hen hen = HenFactory.getHen(Country.BELARUS);
hen.getCountOfEggsPerMonth();
}
static abstract class Hen {
public abstract int getCountOfEggsPerMonth();
public String getDescription() {
return "Я - курица.";
}
}
static class RussianHen extends Hen{
public int getCountOfEggsPerMonth() {
return 10;
}
public String getDescription() {
return super.getDescription() + String.format(" Моя страна - %s. Я несу %d яиц в месяц.", Country.RUSSIA, getCountOfEggsPerMonth());
}
}
static class UkrainianHen extends Hen{
public int getCountOfEggsPerMonth() {
return 11;
}
public String getDescription() {
return super.getDescription() + String.format(" Моя страна - %s. Я несу %d яиц в месяц.", Country.UKRAINE, getCountOfEggsPerMonth());
}
}
static class MoldovanHen extends Hen{
public int getCountOfEggsPerMonth() {
return 12;
}
public String getDescription() {
return super.getDescription() + String.format(" Моя страна - %s. Я несу %d яиц в месяц.", Country.MOLDOVA, getCountOfEggsPerMonth());
}
}
static class BelarusianHen extends Hen{
public int getCountOfEggsPerMonth() {
return 13;
}
public String getDescription() {
return super.getDescription() + String.format(" Моя страна - %s. Я несу %d яиц в месяц.", Country.BELARUS, getCountOfEggsPerMonth());
}
}
static class HenFactory {
static Hen getHen(String country) {
Hen hen = null;
if (country.equals(Country.BELARUS)) hen = new BelarusianHen();
if (country.equals(Country.RUSSIA)) hen = new RussianHen();
if (country.equals(Country.MOLDOVA)) hen = new MoldovanHen();
if (country.equals(Country.UKRAINE)) hen = new UkrainianHen();
return hen;
}
}
}