I'm getting frustrated ..
package com.codegym.task.task15.task1522;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
/*
Reinforce the singleton pattern
*/
public class Solution {
public static void main(String[] args) {
}
public static Planet thePlanet;
// Add static block here
static {
readKeyFromConsoleAndInitPlanet()
}
public static void readKeyFromConsoleAndInitPlanet() {
// Implement step #5 here
try{
Scanner word = new Scanner(System.in);
String s = word.nextLine();
switch(s){
case Planet.SUN:
thePlanet=Sun.getInstance();
break;
case Planet.MOON:
thePlanet = Moon.getInstance();
break;
case Planet.EARTH:
thePlanet = Earth.getInstance();
break;
default;
thePlanet = null;
}
}catch (Exception e){
thePlanet = null;
}
}
}