CS 112 - Introduction to Computer Science II
Individual Exercise #5 |
Due: At the beginning of class 29.
NOTE: This work is to be done independently.
Your assignment submission will consist of a single file: Chomp.java. Testing and grading will be manual. No JUnit test will provide evaluative feedback, so test your application thoroughly.
In this exercise, you will implement Chomp.java, a Java graphical application for hotseat play the game of Chomp.
First, you will utilize these 50-by-50 PNG images. Image "black.png" represents a "chomped" or empty grid cell. Images "cookie-skull.png" and "cookie.png" represents an "unchomped" or non-empty grid cell that are at [0][0] or not at [0][0], respectively. You will load them into your GUI via internet connection, e.g.:
static final String PATH = "http://cs.gettysburg.edu/~tneller/cs112/chomp/images/"; static final Image COOKIE_IMAGE = new Image(PATH + "cookie.png"); static final Image SKULL_IMAGE = new Image(PATH + "cookie-skull.png"); static final Image BLACK_IMAGE = new Image(PATH + "black.png");
Then familiarize yourself with the rules to Chomp. NOTE: Your layout will have poisoned square [0][0] in the upper-left corner of the displayed grid.
Create a Java graphical application for playing Chomp with the following requirements:
For example, when we run our Chomp.java application, the game might look like this grid of black image buttons:
If a user clicks on the button at 0-based row 6, column 7, a new game is set up like this:
If, on the first turn, a player clicks on the button at 0-based row 2, column 5, this would be the resulting state: