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.
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:
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 Vehicle.java 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 Vehicle.java 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 JavaRacer.java file, but it should still use the Player class and the Player.java file should not be modified.
Write the missing "Vehicle.java" file from scratch. It should satisfy the following requirements:
maxSpeed- a floating point number that stores the maximum speed for a vehicle (something in the range of 3-5 is probably adequate)
currentSpeed- the speed of the vehicle as a floating point number
xPos- the current x position of the vehicle as a floating point number
yPos- the current y position of the vehicle as a floating point number
heading- the direction (in degrees ranging from 0-359) that the vehicle is facing;
String toString()- returns a String representation of the object in the form
Vehicle: heading HEADING degrees at SPEEDmph, located at XPOS,YPOS(data in all caps to be replaced with that vehicle's instance data).
boolean equals(Vehicle v)- returns true if all the data associated with this vehicle matches that of Vehicle v, otherwise false
void move()- given the currentSpeed updates the current X and current Y position like so:
xPos += Math.cos(Math.toRadians(heading)) * currentSpeed/maxSpeed; yPos += Math.sin(Math.toRadians(heading)) * currentSpeed/maxSpeed;
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.
Optional for both Honors and Regular students: 5 bonus points
There is a bug with how collision detection works in
JavaRacer.java. It is marked with a
TODO statement. Fix this bug so that collision detection works properly.
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!
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:
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.