Skip to content

Task 2#2

Open
iamAlimzhan wants to merge 2 commits intoFAANG-School:masterfrom
iamAlimzhan:task-2
Open

Task 2#2
iamAlimzhan wants to merge 2 commits intoFAANG-School:masterfrom
iamAlimzhan:task-2

Conversation

@iamAlimzhan
Copy link

No description provided.

@@ -0,0 +1,7 @@
package task_2.solution.exceptions;

public class NoOrdersException extends Exception{
Copy link
Contributor

Choose a reason for hiding this comment

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

RuntimeException

package task_2.solution.exceptions;

public class NotEnoughMaterialException extends Exception{
public NotEnoughMaterialException(String material) {
Copy link
Contributor

Choose a reason for hiding this comment

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

RuntimeException

@@ -0,0 +1,7 @@
package task_2.solution.exceptions;

public class NotEnoughWoodException extends Exception{
Copy link
Contributor

Choose a reason for hiding this comment

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

RuntimeException

}

orders.add(order);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Отступ

coreMaterialCount.put(coreMaterial, availableMaterialCount - requiredMaterialCount);
} else {
throw new NotEnoughMaterialException(coreMaterial);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

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


orders.add(order);
}
public Wand findMostPowerfulWand() throws NoOrdersException{
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional

}
public Wand findMostPowerfulWand() throws NoOrdersException{
if (orders.isEmpty()) {
throw new NoOrdersException("Заказы недоступны");
Copy link
Contributor

Choose a reason for hiding this comment

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

Возвращать пустой Optional, а не кидать исключение

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

Comments