Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object subclass: #Account.
- Account instanceVariableNames: 'balance'.
- Account class extend [
- new [
- | r |
- <category: 'instance creation'>
- r := super new.
- r init.
- ^r
- ]
- ]
- Account extend [
- init [
- <category: 'initialization'>
- balance := 0
- ]
- ]
- Account extend [
- spend: amount [
- <category: 'moving money'>
- balance := balance - amount
- ]
- deposit: amount [
- <category: 'moving money'>
- balance := balance + amount
- ]
- ]
- Account extend [
- printOn: stream [
- <category: 'printing'>
- super printOn: stream.
- stream nextPutAll: ' with balance: '.
- balance printOn: stream.
- ]
- ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement