Only condition no.1 and no.4 is satisfied
package com.codegym.task.task14.task1408;
/*
Chicken factory
*/
public class Solution {
public static void main(String[] args) {
Hen hen = HenFactory.getHen(Continent.EUROPE);
Hen hen1 = HenFactory.getHen(Continent.AFRICA);
Hen hen2 = HenFactory.getHen(Continent.ASIA);
Hen hen3 = HenFactory.getHen(Continent.NORTHAMERICA);
System.out.println(hen.getDescription());
System.out.println(hen1.getDescription());
System.out.println(hen2.getDescription());
System.out.println(hen3.getDescription());
}
static class HenFactory {
static Hen getHen(String continent) {
Hen hen = null;
if(continent.equalsIgnoreCase("Europe")) {
hen = new EuropeanHen();
} else if(continent.equalsIgnoreCase("Africa")) {
hen = new AfricanHen();
} else if(continent.equalsIgnoreCase("Asia")) {
hen = new AsianHen();
} else if(continent.equalsIgnoreCase("NorthAmerica")) {
hen = new NorthAmericanHen();
}
return hen;
}
}
}