Happens to be that I also can't seem to understand what is wrong with my moon? maybe it's an eclipse :-)
package com.codegym.task.task15.task1522;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/*
Reinforce the singleton pattern
*/
public class Solution {
public static void main(String[] args) {
}
public static Planet thePlanet;
// Add static block here
static {
try {
readKeyFromConsoleAndInitPlanet();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void readKeyFromConsoleAndInitPlanet() throws IOException {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String key = reader.readLine();
if (key.equals(Planet.EARTH)) {
thePlanet = Earth.getInstance();
}
if (key.equals(Planet.MOON)) {
thePlanet = Moon.getInstance();
}
if (key.equals(Planet.SUN)) {
thePlanet = Sun.getInstance();
}
else {
thePlanet = null;
}
}catch (IOException e)
{
thePlanet = null;
}
// Implement step #5 here
}
}