Skip to content

add - package morozov#23

Open
tacehex wants to merge 1 commit intodemologin:mainfrom
tacehex:main
Open

add - package morozov#23
tacehex wants to merge 1 commit intodemologin:mainfrom
tacehex:main

Conversation

@tacehex
Copy link

@tacehex tacehex commented Sep 3, 2025

Swing. Возможна ошибка при запуске приложения, ибо синтаксис "_" появился с 21 версии Java

Copy link
Owner

@demologin demologin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отличный проект, замечаний практически нет, так по мелочи. Оценка А


if (index >= 0) {
int newIndex = (index + key) % currentAlphabet.length;
if (newIndex < 0) newIndex += currentAlphabet.length;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше было бы индекс сначала перевести в положительную область а уже потом вычислять остаток отделения, чтобы вся отладка была в положительных значениях, но это дело вкуса конечно.

public List<BruteForceResult> bruteForce(String encryptedText) {
List<BruteForceResult> results = new ArrayList<>();

for (int key = 1; key < currentAlphabet.length; key++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если ключ 0 (не зашифровано) то текст испортится.

results.add(new BruteForceResult(decrypted, key, score));
}

results.sort((a, b) -> Integer.compare(b.score, a.score));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тогда уже и все можно было бы стримом сделать

throw new IOException("Нет прав на чтение файла");
}

String content = Files.readString(Paths.get(file.getPath()));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если выделить три переменных то скорость не пострадает, а читать проще

import com.javarush.morozov.core.CaesarCipher;
import com.javarush.morozov.ui.handlers.MessageHandler;

import javax.swing.*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Однозначно +


public class App {
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(() -> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import?


import javax.swing.*;

public class MessageHandler {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Все методы статические, значит нужен приватный конструктор.

import com.javarush.morozov.core.CaesarCipher;
import com.javarush.morozov.ui.handlers.MessageHandler;

import javax.swing.*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok но некоторые (например гуглы) запрещают импорт .*


import com.javarush.morozov.core.FileHandler;

import javax.swing.*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

то же

import com.javarush.morozov.core.FileHandler;
import com.javarush.morozov.ui.handlers.MessageHandler;

import javax.swing.*;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и то же

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants