package com.javarush.task.task14.task1414;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*
MovieFactory
*/
public class Solution {
public static void main(String[] args) throws Exception {
//ввести с консоли несколько ключей (строк), пункт 7
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String s = reader.readLine();
Movie movie = null;
if("cartoon".equals(s)) {
movie = MovieFactory.getMovie(s);
System.out.println(movie.getClass().getSimpleName());
}
else if("thriller".equals(s)) {
movie = MovieFactory.getMovie(s);
System.out.println(movie.getClass().getSimpleName());
}
else if("soapOpera".equals(s)) {
movie = MovieFactory.getMovie(s);
System.out.println(movie.getClass().getSimpleName());
}
else {
movie = MovieFactory.getMovie(s);
break;
}
}
static class MovieFactory {
static Movie getMovie(String key) {
Movie movie = null;
//создание объекта SoapOpera (мыльная опера) для ключа "soapOpera"
if ("soapOpera".equals(key)) {
movie = new SoapOpera();
}
if("cartoon".equals(key)) {
movie = new Cartoon();
}
if("thriller".equals(key)) {
movie = new Thriller();
}
//напишите тут ваш код, пункты 5,6
return movie;
}
}
static abstract class Movie {
}
static class SoapOpera extends Movie {
}
//CLASSES 1
public static class Cartoon extends Movie{
}
public static class Thriller extends Movie {
}
}