Title: Object Interaction
1Object Interaction
- Notes Supplement
- CS 1054 Introduction to Programming in Java
- Spring 2008
2Bank Example Revisited
1000
Bank
BankAccount john
BankAccount marsha
2000
3Object Interaction
Bank
deposit( 200 )
BankAccount john
1000
deposit( john, 200 )
BankAccount marsha
2000
Calling deposit on the Bank object causes deposit
to be called on a BankAccount object
4Array/ArrayList Version
Bank
BankAccount accounts
deposit( 200 )
deposit( 222, 200 )
Calling deposit on the Bank object causes deposit
to be called on a BankAccount object
5Lab 9 ReportCardupdateGradeRecord( )
ReportCard
GradeRecord grades
updateGradeRecord( English, 85 )
changeGrade(85)
--- 85
Calling updateGradeRecord on the ReportCard
objectcauses changeGrade to be called on a
GradeRecord object
6Lab 9 ReportCardgetAverage( )
getGrade()
ReportCard
GradeRecord grades
getGrade()
getAverage()
getGrade()
Calling getAverage on the ReportCard object
causesgetGrade to be called on each GradeRecord
object
7Project 4 Grocery and Item
Grocery
Item items
100.00
cash