Друзья, подскажите, пожалуйста, в чем проблема? У меня выполнены не все условия, необходимо еще все классы вынести в отдельные файлы. Но почему не принимает даже первые условия? Например то, что класс Hen должен быть абстрактным?
Заодно подскажите, как вынести классы в отдельные файлы? В IntelijIDEA эта задача не отображается. Спасибо!
package com.javarush.task.task14.task1408;
/*
Куриная фабрика
*/
public class Solution {
public static void main(String[] args) {
Hen hen = HenFactory.getHen(Country.BELARUS);
System.out.println(hen.getDescription());
}
static class HenFactory {
static Hen getHen(String country) {
Hen hen = null;
if (country.equals(Country.RUSSIA)) {
hen = new RussianHen();
} else if (country.equals(Country.UKRAINE)) {
hen = new UkranianHen();
} else if (country.equals(Country.MOLDOVA)) {
hen = new MoldovanHen();
} else if (country.equals(Country.BELARUS)) {
hen = new BelarusianHen();
}
return hen;
}
}
public abstract static class Hen {
public abstract int getCountOfEggsPerMonth();
public String getDescription() {
return "Я - курица";
}
}
public static class RussianHen extends Hen {
public int getCountOfEggsPerMonth() {
int N = (int)(Math.random() * 10);
return N;
}
@Override
public String getDescription() {
return super.getDescription() + ". Моя страна - " + Country.RUSSIA + ". Я несу " + getCountOfEggsPerMonth() + " яиц в месяц.";
}
}
public static class UkranianHen extends Hen {
public int getCountOfEggsPerMonth() {
int N = (int)(Math.random() * 10);
return N;
}
@Override
public String getDescription() {
return super.getDescription() + ". Моя страна - " + Country.UKRAINE + ". Я несу " + getCountOfEggsPerMonth() + " яиц в месяц.";
}
}
public static class MoldovanHen extends Hen {
public int getCountOfEggsPerMonth() {
int N = (int)(Math.random() * 10);
return N;
}
@Override
public String getDescription() {
return super.getDescription() + ". Моя страна - " + Country.MOLDOVA + ". Я несу " + getCountOfEggsPerMonth() + " яиц в месяц.";
}
}
public static class BelarusianHen extends Hen {
public int getCountOfEggsPerMonth() {
int N = (int)(Math.random() * 10);
return N;
}
@Override
public String getDescription() {
return super.getDescription() + ". Моя страна - " + Country.BELARUS + ". Я несу " + getCountOfEggsPerMonth() + " яиц в месяц.";
}
}
}