Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Custom Exception for Business Rules | Custom Exceptions and Guard Clauses
C# Exceptions and Error Handling Practice

bookChallenge: Custom Exception for Business Rules

Uppgift

Swipe to start coding

Create a custom exception and use it to enforce a business rule in a banking scenario. Your goal is to prevent negative deposit amounts by throwing a custom exception when such an attempt is made.

  • Throw a NegativeDepositException if the amount passed to the Deposit method is less than zero.
  • Do not change the account balance if the exception is thrown.
  • If the deposit is valid, add the amount to the account balance.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 2. Kapitel 2
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

Suggested prompts:

Can you explain that in more detail?

What are the main benefits or drawbacks?

Can you give me an example?

close

bookChallenge: Custom Exception for Business Rules

Svep för att visa menyn

Uppgift

Swipe to start coding

Create a custom exception and use it to enforce a business rule in a banking scenario. Your goal is to prevent negative deposit amounts by throwing a custom exception when such an attempt is made.

  • Throw a NegativeDepositException if the amount passed to the Deposit method is less than zero.
  • Do not change the account balance if the exception is thrown.
  • If the deposit is valid, add the amount to the account balance.

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 2
single

single

some-alt