Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Custom Exception for Business Rules | Custom Exceptions and Guard Clauses
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C# Exceptions and Error Handling Practice

bookChallenge: Custom Exception for Business Rules

Oppgave

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

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

Sveip for å vise menyen

Oppgave

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 2. Kapittel 2
single

single

some-alt