Challenge: Guard Clauses with Custom Exceptions
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 6
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Suggested prompts:
Can you explain this in simpler terms?
What are the main benefits or drawbacks?
Can you give me a real-world example?
Génial!
Completion taux amélioré à 4.17
Challenge: Guard Clauses with Custom Exceptions
Glissez pour afficher le menu
Tâche
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.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 6
single