Any help would be much appreciated. It says that "The readKeyFromConsoleAndInitPlanet method must be called in the Solution class's static block." when it clearly is, as are all of the unmet conditions.Especially the last condition which is all of the classes to be in different files :/
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 {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
readKeyFromConsoleAndInitPlanet(br.readLine());
} catch (IOException e) {
System.out.println("Not a legit planet");
}
}
public static void readKeyFromConsoleAndInitPlanet(String thePlanet1) {
// Implement step #5 here
if (thePlanet1.equals("earth"))
thePlanet = Earth.getInstance();
else if (thePlanet1.equals("moon"))
thePlanet = Moon.getInstance();
else if (thePlanet1.equals("sun"))
thePlanet = Sun.getInstance();
else
thePlanet = null;
}
}