" CS 1621 Fall 2005 Example of a new Smalltalk class Most of the syntax below is not too tough to figure out. Some of it is similar to Java in idea. " Object subclass: #Person instanceVariableNames: 'name address age salary ' classVariableNames: '' poolDictionaries: '' ! !Person class methods ! ! !Person methods ! address "return address of receiver person" ^address! age "return age of receiver person" ^age! getData | s | s := Prompter prompt: 'Name? ' default: ''. name := s. s := Prompter prompt: 'Address? ' default: ''. address := s. s := Prompter prompt: 'Age? ' default: ''. age := s asInteger. s := Prompter prompt: 'Salary? ' default: ''. salary := s asInteger. ^self! getDataF: aFile " get an object from a file " name := aFile nextLine. address := aFile nextLine. age := (aFile nextLine) asInteger. salary := (aFile nextLine) asInteger. ^self! name "return name of receiver person" ^name! salary "return salary of receiver person" ^salary! printString | w | w := WriteStream on: String new. w nextPutAll: 'Name: ' ; nextPutAll: name ; nl ; nextPutAll: 'Address: ' ; nextPutAll: address ; nl ; nextPutAll: 'Age: ' ; nextPutAll: (age printString) ; nl ; nextPutAll: 'Salary: ' ; nextPutAll: (salary printString). ^(w contents)! !