Conversation
Khmelov
left a comment
There was a problem hiding this comment.
Есть вопросы к архитектуре, но зато сделано три из четырёх алгоритмов, поэтому поставил оценку б
| @@ -0,0 +1,31 @@ | |||
| package com.javarush.trukhanova; | |||
There was a problem hiding this comment.
Даже для небольших приложений всё равно полезно разбивать все на отдельные пакеты
| package com.javarush.trukhanova; | ||
|
|
||
| public abstract class AbstractCipher { | ||
| char[] alphabet = { |
There was a problem hiding this comment.
Если кто-то начнёт наводить порядок в приложении и переносить все в отдельные пакеты то данные поля перестанут корректно работать, тут лучше установить требуемые модификаторы доступа
|
|
||
| public class BruteForceDecryptor extends AbstractCipher{ | ||
| @Override | ||
| public String process(String inputText, int key) { |
There was a problem hiding this comment.
Это неудачное решение, оно нарушает несколько принципов SOLID
|
|
||
| public class Decryptor extends AbstractCipher{ | ||
| @Override | ||
| public String process(String inputText, int key) { |
There was a problem hiding this comment.
Шифратор и дешифратор отличаются только флагом поэтому данный метод лучше вынести в абстракцию
|
|
||
| public class FileService { | ||
| public static void write(String filePath, String content) throws Exception { | ||
| try (BufferedWriter fileWriter = new BufferedWriter( |
There was a problem hiding this comment.
Советую посмотреть пакет nio там есть подходящие методы
| new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) { | ||
| StringBuilder resultBuilder = new StringBuilder(); | ||
| String line; | ||
| while ((line = fileReader.readLine()) != null) { |
| String ENTER_ACTION = "Введите номер действия: "; | ||
| String ENTER_INPUT_PATH = "Введите путь к исходному файлу (или Enter): "; | ||
| String ENTER_KEY = "Введите ключ (целое число): "; | ||
| String ENCRYPTED = "✅ Текст зашифрован и сохранён в: "; |
| String inputFilePath = scanner.nextLine(); | ||
| if (inputFilePath.isBlank()) { | ||
| if (choice == 1) { | ||
| inputFilePath = "text/text.txt"; // для шифрования |
There was a problem hiding this comment.
Не очень хорошо то что именно файлов указаны жёстко а разделители привязаны к определённой операционной системе
No description provided.