I have here such a code I was given the task of breaking the method into classes so that polymorphism would be used. Help a good idea what can be done here?
private void start() { System.out.println("ΠΠΎΠΌΠΎΡΡ: \"h\""); ArrayList<String> target = null; String command; try (Scanner scanner = new Scanner(System.in)) { command = scanner.nextLine(); while (!"q".equals(command)) { if ("-f".equals(command)) { // ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΄Π΅Π»Π°ΡΡ System.out.println("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΏΠΎΠ»Π½ΠΎΠ΅ ΠΈΠΌΡ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΠΈ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° Π² ΡΠΎΡΠΌΠ°ΡΠ΅ \"absolute path.../dir\":"); Dir dir = new Dir(scanner.nextLine()); System.out.println("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΈΠΌΡ ΡΠ°ΠΉΠ»Π° Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ°:"); target = dir.searchByName(scanner.nextLine()); target.forEach(System.out::println); } else if ("-r".equals(command)) { System.out.println("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΏΠΎΠ»Π½ΠΎΠ΅ ΠΈΠΌΡ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΠΈ Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ° Π² ΡΠΎΡΠΌΠ°ΡΠ΅ \"absolute path.../dir\":"); Dir dir = new Dir(scanner.nextLine()); System.out.println("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΡΠ°ΡΡΡ ΠΈΠΌΠ΅Π½ΠΈ ΡΠ°ΠΉΠ»Π° Π΄Π»Ρ ΠΏΠΎΠΈΡΠΊΠ°:"); target = dir.searchRegExp(scanner.nextLine()); System.out.println("ΠΠ°ΠΉΠ΄Π΅Π½ΠΎ:"); target.forEach(System.out::println); } else if ("-o".equals(command)) { if (target != null) { System.out.println("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΏΠΎΠ»Π½ΠΎΠ΅ ΠΈΠΌΡ Π΄ΠΈΡΠ΅ΠΊΡΠΎΡΠΈΠΈ ΠΊΡΠ΄Π° ΡΠΎΡ
ΡΠ°Π½ΠΈΡΡ ΡΠ°ΠΉΠ» Π² ΡΠΎΡΠΌΠ°ΡΠ΅ \"absolute path.../dir/\":"); String path = scanner.nextLine(); System.out.println("ΠΠ²Π΅Π΄ΠΈΡΠ΅ ΠΈΠΌΡ ΡΠ°ΠΉΠ»Π° Π² ΡΠΎΡΠΌΠ°ΡΠ΅ \"file.extension\":"); String name = scanner.nextLine(); // ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΠΊΠ°ΡΠ°Π»ΠΎΠ³ ΠΊΡΠ΄Π° ΡΠΎΡ
ΡΠ°Π½ΡΡΡ if (this.exist(path, name)) { this.write(target, path + name); } else { System.out.println("ΠΠ΅ΠΉΡΡΠ²ΠΈΠ΅ Π½Π΅ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ."); } } } else if ("h".equals(command)) { printManual(); } else { System.err.println("ΠΠ΅ΠΈΠ·Π²Π΅ΡΡΠ½Π°Ρ ΠΊΠΎΠΌΠ°Π½Π΄Π°."); printManual(); } command = scanner.nextLine(); } } }
ΠΠΎΠΌΠ°Π½Π΄Π°and make it? - Alexey Shimansky