RU beehive logo ITEC dept promo banner
ITEC 120
2012fall
dbraffitt
ibarland

homeinfolectslabsexamshws
tutor/PIsbreeze (snow day)
Object120 + its docsjava.lang docsjava.util docs

lab07b
Mutation, continued
considering data representation; hw05 time

We decided previously, that a Student contained several pieces of information, including a gpa and a total # of credits.

Can you write getGpa, for this version?

Suppose new Student( "Amy Aimer", "ITEC", 3.5, 30 ) gets an A in a four-credit-hour class. What is her new gpa?
(discuss)

From this discussion, we realize that there are three related pieces of information: total credits, total grade-points, and grade-point average. Any two of these three things determines the third. So we won't keep track of all three — just two. But which two? We originally had gpa and total-credits, but this is a bit unwieldy for the real computation, isn't it?

For hw05, you'll get to change the Student representation to instead store total credits and total grade-points. You can re-write getGPA so that it still gives the correct answer — and anybody else who'd been calling getGPA previously doesn't care about the fact that you changed your data representation!


For the remainder of today, you can work on hw05—Modifying objects: Student gpas, which takes your previous class Student and lets you (a) incorporate the changes discussed in lab above, and (b) finish/tweak any methods not completed in lab.

homeinfolectslabsexamshws
tutor/PIsbreeze (snow day)
Object120 + its docsjava.lang docsjava.util docs


©2012, Ian Barland, Radford University
Last modified 2012.Oct.17 (Wed)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme