Due: Wednesday, Sept 22nd by 11:59 PM
Acknowledgment: The idea for this assignment comes from Tom Ellman at Vassar College.
In this assignment, you are not implementing a complete game. You are just implementing one (important) class the game will use. In the next assignment you will complete the rest of the game.
Downlaod CS201_Assign2.zip. Import it into your Eclipse workspace (File->Import->General->Existing Projects into Workspace->Archive File.)
You should see a project called CS201_Assign2 in the Package Explorer.
In this assignment you will begin the implementation of the "Disk Placement" game. Here is a screenshot of what the completed game will look like:
The goal is to place disks of random sizes and colors onto the game board so that
The solid disks are the ones that have been successfully placed. The black disk outline follows the mouse and shows where the next disk could be placed. The number in the lower right-hand corner shows the number of disks that have been successfully placed.
The game ends when a disk is placed in a position where it overlaps another disk, or is not entirely placed within the game board:
You can download my implementation of the game to see how it works:
[Note: Internet explorer incorrectly renames this file to "disks.zip". You can work around this problem by downloading the file using Firefox.]
On Windows systems, just double-click on the file. On Linux and MacOS, open a terminal window, change directory into the directory in which you saved the file, and run the command
java -jar disks.jar
Your task is to complete the implementation of the Disk class. (In the next assignment, you will use your Disk class to complete the implementation of the overall game.)
An instance of the Disk class represents one of the disks placed on the game board. Each Disk object should store x and y coordinates, a radius, and a color (represented as a reference to a java.awt.Color object). You should add fields to the class for each of these 4 properties.
You must implement 7 methods:
Each method is described by a comment which explains, in detail, how the method should work.
A JUnit test class called DiskTest is provided. Make sure that all of the tests pass before you submit the completed assignment.
You can compute the square root of a double value using the Math.sqrt method. For example, you can compute the distance between the centers of two Disk objects as follows:
Disk a = ... Disk b = ... double xDist = a.getX() - b.getX(); double yDist = a.getY() - b.getY(); double dist = Math.sqrt( (xDist*xDist) + (yDist*yDist) );
Export your finished program to a zip file (right-click on the project, then Export...->Archive File). Upload the zip file to the marmoset server as project assign2. The server URL is
IMPORTANT: after uploading, you should download a copy of your submission and double-check it to make sure that it contains the correct files. You are responsible for making sure your submission is correct. You may receive a grade of 0 for an incorrectly submitted assignment.