| ||
Student Originated Software 1997-1998
| ||
A Software Engineering Course at The Evergreen State College | ||
|
Smalltalk Code Examples - FinancialHistorySpendingHistory subclass: #FinancialHistory instanceVariableNames: 'incomes ' classVariableNames: '' poolDictionaries: '' category: 'Financial Tools'! !FinancialHistory methodsFor: 'inquiries'! totalReceivedFor: reason "return the amount received from reason. Answer 0 if reason not used for incomes" ^(incomes includesKey: reason) ifTrue: [incomes at:reason] ifFalse: [0]! ! !FinancialHistory methodsFor: 'private'! setInitialBalance: anAmount super setInitialBalance: anAmount. incomes := Dictionary new.! ! !FinancialHistory methodsFor: 'printing'! printOn:aStream super printOn:aStream. aStream space. incomes keysAndValuesDo: [:reason :amount | aStream cr. reason printOn: aStream. aStream tab. amount printOn: aStream]! ! !FinancialHistory methodsFor: 'transactions'! receive: anAmount for: reason "Receive anAmount for a reason and increase the cashOnHand" incomes at: reason put: (self totalReceivedFor:reason) + anAmount. cashOnHand := cashOnHand + anAmount.! ! Posted Nov 3, 1997
|