Conversation
demologin
left a comment
There was a problem hiding this comment.
Отличный проект, замечаний практически нет, так по мелочи. Оценка А
|
|
||
| if (index >= 0) { | ||
| int newIndex = (index + key) % currentAlphabet.length; | ||
| if (newIndex < 0) newIndex += currentAlphabet.length; |
There was a problem hiding this comment.
Лучше было бы индекс сначала перевести в положительную область а уже потом вычислять остаток отделения, чтобы вся отладка была в положительных значениях, но это дело вкуса конечно.
| public List<BruteForceResult> bruteForce(String encryptedText) { | ||
| List<BruteForceResult> results = new ArrayList<>(); | ||
|
|
||
| for (int key = 1; key < currentAlphabet.length; key++) { |
There was a problem hiding this comment.
если ключ 0 (не зашифровано) то текст испортится.
| results.add(new BruteForceResult(decrypted, key, score)); | ||
| } | ||
|
|
||
| results.sort((a, b) -> Integer.compare(b.score, a.score)); |
There was a problem hiding this comment.
тогда уже и все можно было бы стримом сделать
| throw new IOException("Нет прав на чтение файла"); | ||
| } | ||
|
|
||
| String content = Files.readString(Paths.get(file.getPath())); |
There was a problem hiding this comment.
Если выделить три переменных то скорость не пострадает, а читать проще
| import com.javarush.morozov.core.CaesarCipher; | ||
| import com.javarush.morozov.ui.handlers.MessageHandler; | ||
|
|
||
| import javax.swing.*; |
|
|
||
| public class App { | ||
| public static void main(String[] args) { | ||
| javax.swing.SwingUtilities.invokeLater(() -> { |
|
|
||
| import javax.swing.*; | ||
|
|
||
| public class MessageHandler { |
There was a problem hiding this comment.
Все методы статические, значит нужен приватный конструктор.
| import com.javarush.morozov.core.CaesarCipher; | ||
| import com.javarush.morozov.ui.handlers.MessageHandler; | ||
|
|
||
| import javax.swing.*; |
There was a problem hiding this comment.
Ok но некоторые (например гуглы) запрещают импорт .*
|
|
||
| import com.javarush.morozov.core.FileHandler; | ||
|
|
||
| import javax.swing.*; |
| import com.javarush.morozov.core.FileHandler; | ||
| import com.javarush.morozov.ui.handlers.MessageHandler; | ||
|
|
||
| import javax.swing.*; |
Swing. Возможна ошибка при запуске приложения, ибо синтаксис "_" появился с 21 версии Java