Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object subclass: Account [
- | balance |
- <comment:
- 'I represent a place to deposit and withdraw money'>
- Account class >> new [
- <category: 'instance creation'>
- | r |
- r := super new.
- r init.
- ^r
- ]
- init [
- <category: 'initialization'>
- balance := 0.
- 'initialized Account' printNl
- ]
- say [
- "say hello"
- ('I am account of balance "', balance printString, '".') printNl
- ]
- compute: val [
- | tar |
- tar := 3.
- balance := balance + val.
- ]
- mutate: array [
- (array at: 2) printNl.
- "array at: 2 put: -9." "NOTE: argument mutation is not allowed"
- ]
- ]
- cl := [:x | |y| y := x + 1. "This is y = "
- ('This is y = ', y printString) printNl].
- ('y is ', y printString) printNl.
- x0 := 1.
- acc := Account new.
- acc say.
- acc compute: x0.
- acc say.
- acc class printNl.
- array := #(1 2 3).
- acc mutate: array.
- array printNl.
- cl value: 1.
- ('y is ', y printString) printNl.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement