(back to the assignments page)

Objectives

For this assignment, you will:

Description

In this assignment, you will create a graphical version of Bailey’s Silver Dollar Game. Read Section 3.10 of the textbook Java Structures for a description of the game. In this version of the game, the user will use the mouse to move the coins instead of typing commands on the keyboard.

The correctness of the assignments in this class will be automatically verified. For this reason, you must follow all naming conventions specified in this assignment.

Classes

Coin

The Coin class represents a single coin. This class is already implemented for you.

CoinSquare

The CoinSquare class represents a square. This class is already implemented for you.

GraphicsCoinStrip

The GraphicsCoinStrip class uses the Coin and CoinSquare classes to implement the Silver Dollar Game. This class is partially implemented. There are comments suggesting what you need to add. The contains methods that Coin and CoinSquare inherit from Eclipse2D and Rectangle2D may be helpful.

Notice that there are no play or move methods in the GraphicsCoinStrip class because the mouse is in control of the game. Much of what drives the game is the mouse event handling which can be found in the inner class CoinMouseListener inside the GraphicsCoinStrip class. The purpose of the inner class CoinMouseListener is to encapsulate all of the methods that deal with the mouse.

You can add whatever methods you think would be useful to the GraphicsCoinStrip or CoinMouseListener classes, but do not change the names of any of the existing methods or variables.

After you have a working copy of the game, write a method in this class that checks to see if the game is over and, if so, signal this to the user in some fashion.

Possible examples are to print out a message to the console, or better, change the color of all of the coins. You can also make sure that the coins no longer move once the game is completed (although this is not required).

Getting Started

  1. Read through the CS 062 style guide (also listed on the course web page under Documentation and Handouts). You must follow these guidelines for all of your assignments.
  2. Create a new Java project in Eclipse named Assignment01. Add the BAILEY variable to the project. If you’ve forgotten how to do this, see the instructions from the lab here.
  3. Using Finder, copy the starter files for this assignment into the src directory of your newly created project. The starter files can be found at /common/cs/cs062/assignments/assignment01 inside of the silverdollar directory. Copy the entire silverdollar directory over into your src directory (“silverdollar” is the package name), and also grab the asg01.json file, which you’ll need to submit (you can just put it on your Desktop for now).
  4. Refresh your project in Eclipse.
  5. The Coin and CoinSquare classes are complete. You do not need to modify them. However, take a look at them to see what methods are available.
  6. You are now ready to get started! This assignment asks you to fill in the constructor and add the appropriate methods in the GraphicsCoinStrip class to play the game. As much as possible, try and develop incrementally. That is, get one small piece working and then move on to another piece.
  7. When you are done, look at the submitting your work section. You should submit this assignment as asg01.

Grading

You will be graded based on the following criteria:

Criterion Points
Game starts with random coin positions 1
Coins can be dragged 1
Coins can be dragged multiple squares 1
Dropped coins end up centered in correct location 1
Illegal moves are not allowed 3
Game over is indicated somehow 2
General correctness 2
Appropriate comments (including JavaDoc) 2
Style and formatting 2
General correctness 2
Submitted correctly 1

NOTE: Code that does not compile will not be accepted! Make sure that your code compiles before submitting it.

Submitting Your Work

  1. Before you submit, you must comment your code. We will be using the JavaDoc commenting style. To be compliant with JavaDoc, you must have the following:

  2. Follow the directions for submitting on the documentation page. This assignment should be submitted as asg01.

NOTE: If you submit multiple times, we will grade the latest submission, and assess any late penalty based on when it was submitted.