Start Over


 O About this book

 O Ordering Info

 O Order now

 O Java Methods A&AB, AP Edition

 O Java Methods Test Package

 O 250 MC Questions in Java

 O Links

 O Workshops

 O Skylight's home page

 

 

Be Prepared for the AP* Computer Science Exam
in Java

Appendix: MBS in Java 5.0

When compiled in Java 5.0, the Marine Biology Simulation case study generates a few warnings.  (Java 5.0 is NOT required for the May 2006 exam and the case study code runs fine with the warnings.)  The code below implements several cosmetic changes that eliminate these warnings and illustrate the use of the generic ArrayList class in Java 5.0.  We have also updated the Location class for type-specific Comparable and replaced a couple of for loops with "for each" loops in Simulation and Fish. All the changes are marked with
    // *** Java 5.0 ***
To use the modified classes just add them to the project.  There is no need to update mbsbb.jar.

Modified Classes

Summary of Changes:

Environment
the return type of the neighborsOf method changed to ArrayList<Location>
SquareEnvironment
the return type and a couple of statements in neighborsOf
UnboundedEnvironment
ArrayList objectList changed to ArrayList<Locatable>; removed redundant casts; replaced the for loop with a "for each" loop in recordMove
Location
updated to implement Comparable<Location>
Fish (and Original-Fish)
updated the nextLocation and emptyNeighbors methods; also updated breed in Fish
Simulation
replaced the for loop in step with a "for each" loop




 

Copyright © 2005 by Skylight Publishing
support@skylit.com