I think my code adheres to the requirements laid out in the exercise but it fails the fourth, sixth and seventh requirements despite having compiled and run without errors.
Suggestions are much appreciated.
package com.codegym.task.task14.task1408;
/*
Chicken factory
*/
public class Solution {
public static void main(String[] args) {
Hen hen = HenFactory.getHen(Continent.AFRICA);
hen.getMonthlyEggCount();
}
static class HenFactory {
static Hen getHen(String continent) {
Hen hen = null;
if(continent.equalsIgnoreCase(Continent.AFRICA))
return new AfricanHen();
else if(continent.equalsIgnoreCase(Continent.ASIA))
return new AsianHen();
else if(continent.equalsIgnoreCase(Continent.EUROPE))
return new EuropeanHen();
else if(continent.equalsIgnoreCase(Continent.NORTHAMERICA))
return new NorthAmericanHen();
else return hen;
}
}
public static abstract class Hen {
abstract int getMonthlyEggCount();
public String getDescription() {
return "I am a chicken.";
}
}
}