CSCI.UA0101: Homework 7

Section 001: 35 points + 5 bonus
Section 002: 30 points + 5 bonus


Answer the questions stated in the following exercises by submitting plain-text or Java source code (.txt and .java extensions respectively) as stated in the exercises through NYU Classes. No word (.doc/.docx/etc.) or rich-text (.rtf) files please (in your text editor do "Save file as plain-text"). Java programs should be just the Java source code (not your .class files or Eclipse workspaces) unless otherwise stated.

In all files submitted include a documentation header using comments which include:

 * [Description of the class file]
 * @author: [Your Name]

Points will be deducted for bad coding style (up to 25% of your grade), so:

For more details regarding good coding style guidelines see the grading criteria.

Part 0 - Import an existing project into Eclipse

0 points

This assignment involves updating an existing project's codebase. In order to do so, you'll want to download this compressed eclipse project workspace. To use it you will need to import it into Eclipse. Follow these steps from the Eclipse menu:

  1. Eclipse Menu -> Import
  2. Expand the "General" option
  3. Select "Existing Projects into Workspace" and click "Next"
  4. Choose "Select archive file" and click "Browse"
  5. Locate and choose the "" file you downloaded
  6. Make sure that "JavaRacer" is checked in the list of projects to import, then click "Finish"
The project should have gotten imported and shown up on your list of projects, but you'll notice it can't compile and won't run because there are errors.

Part 1 - Creating an Object Class

25 points

Several files have been included in the project:

There is one file that is missing:

The last developer that worked on this project stole the code for from someone else and in doing so was guilty of copyright infringement. This coder has been fired, and the illegal code expunged from our source code repositories. We need you to write a file from scratch that meets the same specifications so that we don't have to re-write the rest of the program.

If desired, you are allowed to modify the file, but it should still use the Player class and the file should not be modified.

Your job:

Write the missing "" file from scratch. It should satisfy the following requirements:

Part 2 - Collision detection

Required for Honors students (Section 001) - 5 points
Optional for Regular students, but no bonus points awarded

Figure out how the collision detection works between the vehicles and the race track walls. Once you have figured it out, make your own racetrack.png file and replace the one included in the original project with your own. Make sure that the collision detection still works with your new racetrack. You may also need to re-position the player's vehicles so that they are on the racetrack.

Part 3 - Bonus collision detection

Optional for both Honors and Regular students: 5 bonus points

There is a bug with how collision detection works in It is marked with a TODO statement. Fix this bug so that collision detection works properly.

Part 4 - Creating a Runnable JAR

5 points

A JAR file is just a container for that you package up Java related files into to make them easily portable between computers. To submit your project, you're going to build your own runnable JAR file that includes the source code and other resources necessary to run your program. This JAR file will be capable of running on any computer that has Java 1.6+ installed!

Building your JAR file:

Testing your JAR file:

There is a problem with how 3rd party JAR files are packaged when following the instructions in the assignment.

You can test your JAR the following way:

Unzip/Uncompress the JavaRacer.jar file using your favorite compression tool (winzip/unarchiver/etc.). Once it's unzipped, copy the JavaRacer.jar file into that directory. Then the JavaRacer.jar file should be runnable as usual. Try double clicking it. On some systems you may want to switch to the command line, change to the JavaRacer directory which now contains your JavaRacer.jar file and run:

   java -jar JavaRacer.jar

Theoretically, we should be able to run/grade your code if the following were true before submission:

  1. your jar contains the source code (.java) files and any resources files (images, etc.) needed
  2. your code runs fine in your eclipse project
  3. and you've followed the directions online to include the source and resources

Save and submit your entire project's JAR file (make sure you included the source code in the JAR build) on NYU Classes called JavaRacer.jar.