RU beehive logo ITEC Department logo
ITEC 120
2007spring
ibarland,
jpittges

homeinfoexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs

hw-ec04-backpack
extra credit homework: turning pockets into backpacks
hw-ec04; 15pts; Due Apr.20 (Fri) 17:00

Our current for code Explorer is a bit annoying, since there are exactly two pockets. We had lots of places where our code had nearly-repeated code (doing something once for the left-pocket, and then doing it again for the right-pocket).

Modify your Explorer so that it instead of being tied to exactly two Treasures, instead an Explorer has a knapsack, which can hold any number of Treasures (still subject to the weight limit). Go back an purge your code of any mentions of left- or right-pockets.

You'll find this change makes your code not only more powerful (Explorers can now carry 7000 Treasures, if they wanted to), but your it is also simpler and smaller less bug-prone. All hallmarks of a better design! Moreover, it gets rid of the need for lint — which really was just a way to keep from having fields which were uninitialized (which didn't hold a valid Treasure reference).

You'll need to update several methods. Note that inventory will love to make use of the method treasureListToString, needed for hw09. (You can turn in this homework before or after hw09.)


As always, each of the above steps should include unit tests, created with BlueJ's unit test tools.

A general note on extra-credit homeworks:

homeinfoexamslectureslabshws
RecipeLawsliessyntaxjava.lang docsjava.util docs


©2007, Ian Barland, Radford University
Last modified 2007.Aug.27 (Mon)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme