Skip to content

Lab 02#40

Open
mnik0-0 wants to merge 3 commits into
Rrenkens:mainfrom
mnik0-0:lab-02
Open

Lab 02#40
mnik0-0 wants to merge 3 commits into
Rrenkens:mainfrom
mnik0-0:lab-02

Conversation

@mnik0-0

@mnik0-0 mnik0-0 commented Dec 10, 2023

Copy link
Copy Markdown

No description provided.

"unloadingSpeed": 5,
"dockCapacity": 100,
"name": "dock2",
"hoboGroup": {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

На все доки только одна общая группа бродяг.

Gson gson = new Gson();
RootObject rootObject;
try {
FileReader reader = new FileReader("lab-02/by/mnik0_0/docks_and_hobos/config.json");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Все переменные должны задаваться в файле config.json. Путь до этого файла передается аргументов в вашу программу

RootObject rootObject;
try {
FileReader reader = new FileReader("lab-02/by/mnik0_0/docks_and_hobos/config.json");
rootObject = gson.fromJson(reader, RootObject.class);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Зачем json конвертировать в gson?

Comment on lines +62 to +73

for (int i = 0; i < workers; i++) {
String type = getTypeToSteal();
if (type == null) {
continue;
}
if (!dock.getGoodByType(type)) {

int count = ingredientsWeNeed.get(type);
ingredientsWeNeed.put(type, count + 1);
}
}

@Rrenkens Rrenkens Dec 28, 2023

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Вот это должно быть в параллель, а не последовательно.

return dockCapacity;
}

public synchronized boolean getGoodByType(String type) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Тут тогда лучше переписать на синхронизацию по good.

@Rrenkens

Copy link
Copy Markdown
Owner

Основная оценка:

  • -0.5 за путь до файла.
  • -2 за уход от параллельности.

В итоге:
Основная оценка – 7.5.

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