Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Guard Clauses with Custom Exceptions | Custom Exceptions and Guard Clauses
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# Exceptions and Error Handling Practice

bookChallenge: 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 ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 6
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

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?

close

bookChallenge: 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

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 6
single

single

some-alt