Next: Next coming, Previous: A look at our object, Up: Creating classes
We can now create accounts, and look at them. As it stands, though, our balance will always be 0—what a tragedy! Our final methods will let us deposit and spend money. They're very simple:
Account extend [
spend: amount [
<category: 'moving money'>
balance := balance - amount
]
deposit: amount [
<category: 'moving money'>
balance := balance + amount
]
]
With these methods you can now deposit and spend amounts of money. Try these operations:
a deposit: 125
a deposit: 20
a spend: 10