Challenge: Custom Exception for Business Rules
Tâche
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
NegativeDepositExceptionif theamountpassed to theDepositmethod is less than zero. - Do not change the account balance if the exception is thrown.
- If the deposit is valid, add the
amountto the account balance.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 2
single
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Génial!
Completion taux amélioré à 4.17
Challenge: Custom Exception for Business Rules
Glissez pour afficher le menu
Tâche
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
NegativeDepositExceptionif theamountpassed to theDepositmethod is less than zero. - Do not change the account balance if the exception is thrown.
- If the deposit is valid, add the
amountto the account balance.
Solution
Tout était clair ?
Merci pour vos commentaires !
Section 2. Chapitre 2
single