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

bookChallenge: Guard Clauses with Custom Exceptions

Aufgabe

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ösung

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 6
single

single

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

close

bookChallenge: Guard Clauses with Custom Exceptions

Swipe um das Menü anzuzeigen

Aufgabe

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ösung

Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 2. Kapitel 6
single

single

some-alt