Assignment 9: "ARRAYS"
Handed out: Thursday, November 17, 2016 Due: Thursday, December 1, 2016 (last day of class!) Purpose: Learn
- how to use arrays,
- how to declare, create, and manipulate arrays,
- how to an array of objects,
- how to use a FOR loop to traverse an array and act on each element,
- how to use arrays of objects in a complex system (e.g., an animated graphical game).
Assignment:
- Download this code (file "A9code.zip") and uncompress (extract) it.
- All of your instructions are in the comments of file "GameWorld.java".
- Basically, just add code to ten places in "GameWorld" to add an array of targets, just as we did in the example code "Tester_with_arrays.java"
- I've given you a target class file to use in GameWorld (JeffTarget), but feel free to use your own if you wish (just make sure yours properly implements the four "physics methods" of Target: "getXvelocity, getYvelocity, setXYvelocity" and "move").
- There are some additional Targets (class files from other students in the course) for you to try, if you'd like, here.
- What to Modify:
- Only change the file "GameWorld.java".
- And you only need to change it by adding lines of array code in the TEN (10) places identified in the comments of GameWorld.
- Furthermore, the code you need to add is the same as, or very similar to, the code for arrays in "Tester_with_arrays.java". See the code next to comments labeled "array code" in Tester_with_arrays.
- Email your source code to me, just the "GameWorld.java" file. Send the file as an attachment, and include "CS 120: A9" in the subject line as usual. Also put your name in the top line of the file, in a comment of course, in case I separate your code from your email and need to identify whose code I am testing.