Skip to content

Труханова - 3 tasks#28

Open
Trukhanova03 wants to merge 15 commits intodemologin:mainfrom
Trukhanova03:main
Open

Труханова - 3 tasks#28
Trukhanova03 wants to merge 15 commits intodemologin:mainfrom
Trukhanova03:main

Conversation

@Trukhanova03
Copy link

No description provided.

@Trukhanova03 Trukhanova03 changed the title Труханова - 3 taska Труханова - 3 tasks Sep 4, 2025
Copy link

@Khmelov Khmelov left a comment

Choose a reason for hiding this comment

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

Есть вопросы к архитектуре, но зато сделано три из четырёх алгоритмов, поэтому поставил оценку б

@@ -0,0 +1,31 @@
package com.javarush.trukhanova;
Copy link

Choose a reason for hiding this comment

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

Даже для небольших приложений всё равно полезно разбивать все на отдельные пакеты

package com.javarush.trukhanova;

public abstract class AbstractCipher {
char[] alphabet = {
Copy link

Choose a reason for hiding this comment

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

Если кто-то начнёт наводить порядок в приложении и переносить все в отдельные пакеты то данные поля перестанут корректно работать, тут лучше установить требуемые модификаторы доступа


public class BruteForceDecryptor extends AbstractCipher{
@Override
public String process(String inputText, int key) {
Copy link

Choose a reason for hiding this comment

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

Это неудачное решение, оно нарушает несколько принципов SOLID


public class Decryptor extends AbstractCipher{
@Override
public String process(String inputText, int key) {
Copy link

Choose a reason for hiding this comment

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

Шифратор и дешифратор отличаются только флагом поэтому данный метод лучше вынести в абстракцию


public class FileService {
public static void write(String filePath, String content) throws Exception {
try (BufferedWriter fileWriter = new BufferedWriter(
Copy link

Choose a reason for hiding this comment

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

Советую посмотреть пакет nio там есть подходящие методы

new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) {
StringBuilder resultBuilder = new StringBuilder();
String line;
while ((line = fileReader.readLine()) != null) {
Copy link

Choose a reason for hiding this comment

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

То же самое

String ENTER_ACTION = "Введите номер действия: ";
String ENTER_INPUT_PATH = "Введите путь к исходному файлу (или Enter): ";
String ENTER_KEY = "Введите ключ (целое число): ";
String ENCRYPTED = "✅ Текст зашифрован и сохранён в: ";
Copy link

Choose a reason for hiding this comment

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

Иконочки имба

String inputFilePath = scanner.nextLine();
if (inputFilePath.isBlank()) {
if (choice == 1) {
inputFilePath = "text/text.txt"; // для шифрования
Copy link

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