|
home—info—lects—labs—exams—hws
tutor/PIs—breeze (snow day)
Object120 + its docs—java.lang docs—java.util docs
Complete the previous lab, and have your file checked off (for you and your partner).
If you finish that early and want to working on something more,
there is a small amount (4pts max, graded strictly) of extra credit
for completing the following and submitting your improved code to
to D2L > dropbox > lab04b-ec.
(Be sure you also check off your unimproved code above
(perhaps making a backup of it),
before starting on this!)
Make a copy of your entire function
Be sure to factor out any repeated code;
your upgrade should add about five (fairly simple) lines of code,
but should not double the number of lines of code.
hint: Don't think of it as “either multiply all my turns by -1, or do nothing”; instead think of it as “either multiply all my turns by -1, or multiply them by +1.”. This way, the only difference is the particularly number to multiply by. This is reminiscent of the trick we used for getting theplural case right intoppingMsg from yesterday's lecture.
Re-write
Write
Finally, write
1
Actually, in Java you can name both functions
home—info—lects—labs—exams—hws
tutor/PIs—breeze (snow day)
Object120 + its docs—java.lang docs—java.util docs
©2012, Ian Barland, Radford University Last modified 2012.Sep.25 (Tue) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |