Please help, I'm loosing my mind here :(
Every time, no matter how many times I try to do it, i get "pl.codegym.task.task14.task1408.Solution.this' cannot be referenced from a static context".
I checked other users' solutions and I think they don't get the same mistake here, so I'm completely lost...
package pl.codegym.task.task14.task1408;
/*
Ferma drobiu
*/
public class Solution {
public static void main(String[] args) {
Hen hen = HenFactory.getHen(Continent.AFRICA);
hen.getMonthlyEggCount();
}
public abstract class Hen {
abstract int getMonthlyEggCount();
public String getDescription() {
return "Jestem kurczakiem.";
}
}
public class AsianHen extends Hen {
@Override
public int getMonthlyEggCount() {
return 1;
}
@Override
public String getDescription() {
return super.getDescription() + " Pochodzę z " + Continent.ASIA + ". Znoszę " + getMonthlyEggCount() + " jaj na miesiąc.";
}
}
public class AfricanHen extends Hen {
@Override
public int getMonthlyEggCount() {
return 2;
}
@Override
public String getDescription() {
return super.getDescription() + " Pochodzę z " + Continent.AFRICA + ". Znoszę " + getMonthlyEggCount() + " jaj na miesiąc.";
}
}
public class EuropeanHen extends Hen {
@Override
public int getMonthlyEggCount() {
return 3;
}
@Override
public String getDescription() {
return super.getDescription() + " Pochodzę z " + Continent.EUROPE + ". Znoszę " + getMonthlyEggCount() + " jaj na miesiąc.";
}
}
public class NorthAmericanHen extends Hen {
@Override
public int getMonthlyEggCount() {
return 4;
}
@Override
public String getDescription() {
return super.getDescription() + " Pochodzę z " + Continent.NORTHAMERICA + ". Znoszę " + getMonthlyEggCount() + " jaj na miesiąc.";
}
}
static class HenFactory {
static Hen getHen(String continent) {
Hen hen = null;
switch (continent) {
case Continent.EUROPE:
hen = new EuropeanHen();
break;
case Continent.NORTHAMERICA:
hen = new NorthAmericanHen();
break;
case Continent.ASIA:
hen = new AsianHen();
break;
case Continent.AFRICA:
hen = new AfricanHen();
break;
}
return hen;
}
}
}