@@ -0,0 +1,1190 @@
+package com.javarush.task.task14.task1407;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0A%0A/* %0APlayer and Dancer%0A*/%0A%0Apublic class Solution %7B%0A    public static void main(String%5B%5D args) throws Exception %7B%0A        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));%0A%0A        Person person = null;%0A        String key;%0A        while (!(key = reader.readLine()).equals(%22exit%22)) %7B%0A            if (%22player%22.equals(key)) %7B%0A                person = new Player();%0A            %7D else if (%22dancer%22.equals(key)) %7B%0A                person = new Dancer();%0A            %7D%0A            haveRest(person);%0A        %7D%0A    %7D%0A%0A    public static void haveRest(Person person) %7B%0A        //%D0%BD%D0%B0%D0%BF%D0%B8%D1%88%D0%B8%D1%82%D0%B5 %D1%82%D1%83%D1%82 %D0%B2%D0%B0%D1%88 %D0%BA%D0%BE%D0%B4%0A        if (person instanceof Player) %7B%0A            ((Player) person).play();%0A        %7D else if (person instanceof Dancer) %7B%0A            ((Dancer) person).dance();%0A        %7D%0A    %7D%0A%0A    interface Person %7B%0A    %7D%0A%0A    static class Player implements Person %7B%0A        void play() %7B%0A            System.out.println(%22playing%22);%0A        %7D%0A    %7D%0A%0A    static class Dancer implements Person %7B%0A        void dance() %7B%0A            System.out.println(%22dancing%22);%0A        %7D%0A    %7D%0A%7D%0A

Complete task1407