Challenge: Custom Exception for Business Rules
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 2
single
Pergunte à IA
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo
Suggested prompts:
Can you explain that in more detail?
What are the main benefits or drawbacks?
Can you give me an example?
Incrível!
Completion taxa melhorada para 4.17
Challenge: Custom Exception for Business Rules
Deslize para mostrar o menu
Tarefa
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.
Solução
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 2. Capítulo 2
single