Добрый день. Видимо, классический вопрос тут!
Что не там со спутницей Земли?
package com.javarush.task.task15.task1522;
/*
Закрепляем паттерн Singleton
*/
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
}
public static Planet thePlanet;
//add static block here - добавьте статический блок тут
static {
readKeyFromConsoleAndInitPlanet();
}
public static void readKeyFromConsoleAndInitPlanet() {
Scanner scanner = new Scanner(System.in);
String input = scanner.nextLine();
try {
if (Planet.SUN.equals(input)) {
thePlanet = Sun.getInstance();
} else thePlanet = null;
if (Planet.MOON.equals(input)) {
thePlanet = Moon.getInstance();
} else thePlanet = null;
if (Planet.EARTH.equals(input)) {
thePlanet = Earth.getInstance();
} else thePlanet = null;
}
catch (Exception e)
{
e.printStackTrace();
}
// implement step #5 here - реализуйте задание №5 тут
}
}