Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära 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

Uppgift

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.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 6
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

close

bookChallenge: Guard Clauses with Custom Exceptions

Svep för att visa menyn

Uppgift

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.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 6
single

single

some-alt