Not able to pass validation
package com.codegym.task.task14.task1411;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
User, loser, coder and programmer
*/
public class Solution implements Person{
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
Person person = null;
String key = null;
// Here's the loop for reading the keys. Item 1
Boolean loop = true;
while(loop)
{ key = reader.readLine();
// Create an object. Item 2
switch(key){
case "user": person = new User();
doWork(person);
break;
case "loser": person = new Loser();
doWork(person);
break;
case "coder": person = new Coder();
doWork(person);
break;
case "programmer": person = new Programmer();
doWork(person);
break;
default: loop = false;
break;
}
//doWork(person); // Call doWork
}
}
public static void doWork(Person person) {
// Item 3
//System.out.println(person.getClass().getSimpleName());
switch (person.getClass().getSimpleName()){
case "User": ((User) person).live();
break;
case "Loser": ((Loser) person).doNothing();
break;
case "Coder": ((Coder) person).writeCode();
break;
case "Programmer": ((Programmer) person).enjoy();
break;
}
}
}