| ||
Student Originated Software 1997-1998
| ||
A Software Engineering Course at The Evergreen State College | ||
|
Smalltalk Code Examples - SpendingObject subclass: #SpendingHistory instanceVariableNames: 'cashOnHand expenditures ' classVariableNames: '' poolDictionaries: '' category: 'Spending' SpendingHistory methodsFor: 'transactions' spend:anAmount on:reason expenditures at: reason put: (self totalSpentOn: reason) + anAmount. cashOnHand := cashOnHand - anAmount.! ! SpendingHistory methodsFor: 'printing' printOn:aStream super printOn:aStream. aStream space. aStream nextPutAll: 'balance:'. cashOnHand printOn: aStream. expenditures keysAndValuesDo: [:reason :amount | aStream cr. reason printOn: aStream. aStream tab. amount printOn: aStream] SpendingHistory methodsFor: 'inquiries' totalSpentOn: reason (expenditures includesKey: reason) ifTrue:[^expenditures at:reason] ifFalse:[^0] SpendingHistory methodsFor: 'private' setInitialBalance: anAmount cashOnHand := anAmount. expenditures := Dictionary new. "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" SpendingHistory class instanceVariableNames: '' !SpendingHistory class methodsFor: 'instance creation' initialBalance:anAmount ^self new setInitialBalance:anAmount Posted Nov 3, 1997
|