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

bookChallenge: Custom Exception for Business Rules

Tehtävä

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.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 2
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: Custom Exception for Business Rules

Pyyhkäise näyttääksesi valikon

Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 2. Luku 2
single

single

some-alt