Skip to content

Karpeev - 3 tasks complete#32

Open
VitalyKarpeev wants to merge 9 commits intodemologin:mainfrom
VitalyKarpeev:main
Open

Karpeev - 3 tasks complete#32
VitalyKarpeev wants to merge 9 commits intodemologin:mainfrom
VitalyKarpeev:main

Conversation

@VitalyKarpeev
Copy link

No description provided.

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.

Приложение написано неплохо есть небольшие замечания по компоновки элементов и методов. Работают три функции из четырёх. Поставил оценку б


import java.util.Arrays;

public class CryptText {
Copy link

Choose a reason for hiding this comment

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

TextCryptor? TextCryptoProcessor?

public class CryptText {
public char[] encrypt(char[] arrayInputText, int key) {
char[] arrayOutputText = new char[arrayInputText.length];
for (int i = 0; i < arrayInputText.length; i++) {
Copy link

Choose a reason for hiding this comment

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

Вижу два практически одинаковых метода

return arrayOutputText;
}

public char[] decrypt(char[] arrayInputText, int key) {
Copy link

Choose a reason for hiding this comment

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

Использовать массив букв обычно намного менее удобно чем строку или стринг билдер

return arrayOutputText;
}

public int bruteForce(char[] arrayDecodeText) {
Copy link

Choose a reason for hiding this comment

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

Три разных по функциям метода расположены в одном классе, лучше было сделать три разных

return correctKey;
}

public int isCorrectKey(char[] arrayChar, int i) {
Copy link

Choose a reason for hiding this comment

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

Мне кажется этот метод можно сделать приватным

}

private void foundKey() {
FileManager fileManager = new FileManager();
Copy link

Choose a reason for hiding this comment

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

И это тоже

@@ -0,0 +1,26 @@
package com.javarush.karpeev.constants;
public class Constants {
Copy link

Choose a reason for hiding this comment

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

Тут всё хорошо но не хватает приватного конструктора

@@ -0,0 +1,22 @@
package com.javarush.karpeev.constants;

public class Message {
Copy link

Choose a reason for hiding this comment

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

То же самое. Ну и теперь все мы знаем что для этих целей полезно использовать интерфейс

import java.io.IOException;

public class FileForReadNotFoundException extends IOException {
public FileForReadNotFoundException() {
Copy link

Choose a reason for hiding this comment

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

При таком дизайне в случае необходимости нельзя будет передать причину возникновения данного исключения


public char[] varyTextInArrayChar(String addressText) throws FileForReadNotFoundException {
StringBuilder textBuffer = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader(addressText))) {
Copy link

Choose a reason for hiding this comment

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

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

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