Student Originated Software 1997-1998
Fall Quarter

A Software Engineering Course at
The Evergreen State College

ARCHIVE -

Smalltalk Code Examples - FinancialHistory






SpendingHistory 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
Pavan Auman

[ SOS Home Page | Case Study | Year Long Projects | OOP ]


For more information contact
[ Evergreen Home Page | Academic Programs ]


Created by: SoSwEbGrOuP
E-mail: ringert@evergreen.edu