Challenge: Guard Clauses with Custom Exceptions
Tarefa
Swipe to start coding
Implement a method for a product ordering system that enforces stock limits using guard clauses and a custom exception.
- If the requested quantity is greater than the available stock, the method must throw an
OutOfStockException. - If the requested quantity is within the available stock, the stock must be reduced by the ordered quantity.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 6
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Incrível!
Completion taxa melhorada para 4.17
Challenge: Guard Clauses with Custom Exceptions
Deslize para mostrar o menu
Tarefa
Swipe to start coding
Implement a method for a product ordering system that enforces stock limits using guard clauses and a custom exception.
- If the requested quantity is greater than the available stock, the method must throw an
OutOfStockException. - If the requested quantity is within the available stock, the stock must be reduced by the ordered quantity.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 6
single