Skip to content

Dev#1

Open
effgang wants to merge 7 commits into
mainfrom
dev
Open

Dev#1
effgang wants to merge 7 commits into
mainfrom
dev

Conversation

@effgang

@effgang effgang commented Dec 13, 2023

Copy link
Copy Markdown
Owner

No description provided.

@antonkupreychik antonkupreychik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Отличный проект!

Comment thread README.md
@@ -1 +1,23 @@
# Island
## Description

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

за реадми лайк

Comment on lines +22 to +52
int ans;
try {
ans = scanner.nextInt();
if (ans < 0 || ans > 5) {
System.out.println(Constant.INVALID_NUMBER_PLEASE_TRY_AGAIN);
continue;
}
} catch (InputMismatchException e) {
String badValue = scanner.nextLine();
System.out.println(Constant.IT_S_NOT_A_NUMBER + badValue);
continue;
}

if (ans != 5) {
System.out.print(Constant.WRITE_THE_PARAMETER_VALUE);
}
if (ans == 1) {
paramType = Constant.MAP_WIDTH;
}
if (ans == 2) {
paramType = Constant.MAP_HEIGHT;
}
if (ans == 3) {
paramType = Constant.COUNT_ENTITIES_IN_ONE_LOCATION;
}
if (ans == 4) {
paramType = Constant.LIFE_CYCLE_OF_SIMULATION;
}
if (ans == 5) {
break;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

это можно вынести в отдельный сервис ввода данных, чтобы было более читаемо и был нормальный код. Плюс можно вынести в enum и сделать вот так
enum SomeEnum {
VALUE(1, Constant.WRITE_THE_PARAMETER_VALUE),
VALUE2(2, Constant.MAP_WIDTH) и так далее и сделать switch case на этот enum

}

@Override
public void doEat(Animal animal, Location location) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Comment on lines +57 to +68
int currentX = location.getX();
int currentY = location.getY();
if (currentX < map.getWidth() - 1) {
Location newLocation = map.getLocations()[currentY][currentX + 1];
if (cantStep(animal, newLocation)) {
return location;
}
newLocation.addEntity(animal);
location.removeEntity(animal);
return newLocation;
}
return location;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

все методы шаблонные - подумай как можно сократить кол-во кода

import java.io.IOException;
import java.util.Properties;

public class Processor {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

весь этот класс можно было вынести на два-три метода, String getValue(String param, String key)
и Doube getValue(String param, String key) и int getValue(String param, String key)
где key был бы ".emoji" или ".weight" и так далее

import java.util.concurrent.ConcurrentHashMap;

public class Statistic {
public static final String EMOJI_KEY_VALUE = "{0} - {1}";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Тут точно нужна public переменная?

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