It doesn't verify the last condition: "The HenFactory class's getHen method must return a NorthAmericanHen object if Continent.NORTHAMERICA is passed as an argument."
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;
switch (continent) {
case Continent.NORTHAMERICA:
hen = new NorthAmericanHen();
break;
case Continent.EUROPE:
hen = new EuropeanHen();
break;
case Continent.AFRICA:
hen = new AfricanHen();
break;
case Continent.ASIA:
hen = new AsianHen();
break;
}
return hen;
}
}
}