Skip to content

Conversation

@South12309
Copy link

Task 2 is done

build.gradle Outdated
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.2'
// compileOnly 'org.projectlombok:lombok'
// annotationProcessor 'org.projectlombok:lombok'
Copy link
Contributor

Choose a reason for hiding this comment

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

Не оставляем комменты

import java.util.Map;

public class OlivandersShop {
List<WandOrder> orders = new ArrayList<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

private поле


public Wand findMostPowerfulWand() throws OrdersListIsEmptyException {
if (orders.isEmpty()) {
throw new OrdersListIsEmptyException("Список заказов пуст");
Copy link
Contributor

Choose a reason for hiding this comment

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

Можно использовать пустой Optional

Copy link
Author

Choose a reason for hiding this comment

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

По подсказке 1 должно выбрасываться исключение с этим именем.

Integer coreMaterialCnt = coreMaterialCount.get(coreMaterial);
if (coreMaterialCnt == null || coreMaterialCnt < order.getQuantity()) {
throw new NotEnoughMaterialException(woodType);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Дубликация кода. Можно вынести в приватный метод

try {
System.out.println(olivandersShop.findMostPowerfulWand());
} catch (OrdersListIsEmptyException e) {
throw new RuntimeException(e);
Copy link
Contributor

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