Course of Raku / Addendum 🆕 / Types and text machines / Objects and classes / Exercises

A bank account

Problem

Write an Account class with a balance that starts at 0, a deposit method, and a withdraw method that refuses (with a message) when there is not enough money. Deposit 100, withdraw 30, try to withdraw 200, then print the balance.

Example

The program prints:

declined: insufficient funds
70

Solution

See the solution

Course navigation

Solution: A stack class   |   Solution: A bank account