I'm trying to check where my code goes wrong by printing the output to the console. However the only output I get is the reference. Can someone please explain how I can check the proper String output?
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();
System.out.println(hen);
}
static class HenFactory {
static Hen getHen(String continent) {
Hen hen = null;//initialize the instance variable hen of type Hen
if(continent.equals(Continent.AFRICA))
{
hen = new AfricanHen();//create an instance of an African hen
}
else if(continent.equals(Continent.NORTHAMERICA))
{
hen = new NorthAmericanHen();
}
else if(continent.equals(Continent.EUROPE)){
hen = new EuropeanHen();
}
else if(continent.equals(Continent.ASIA)){
hen = new AsianHen();
}
//System.out.println(hen);
return hen;
}
}
}