Make-up Assignment 2

COMP102/112 2022 Tri 1: Make-up Assignment 2:

days Due 3 Jun 10am

ALERT! This assignment is for students who have not submitted more than one of assignments 1 - 10, and are therefore likely to fail the mandatory requirement to submit reasonable attempts at 8 out of the 10 assignments (assignments 1 to 10).

ALERT! The assignment will not be marked, and only has a Core requirement. But submitting a reasonable attempt will help you meet the mandatory requirements. Solutions are not provided.


The assignment addresses using GUI's and 2D arrays.


Download the zip file for MakeUp 2 and extract it to your home folder. It should contain templates for the Java program you are to complete. Read through the whole assignment to see what you need to do.

You may look at the model answers to assignments 9 and 10 to ensure you understand how to use arrays.

To Submit

  • Your program.


The GoGame program allows two users to play a game of Go on the screen.


Go is a very old game from China. It is played with black and white stones on a 19 x 19 grid. The two players take turns placing a stone of their color on the grid. Sometimes, a player may capture some of the opponent's stone(s), in which case they can remove the captured stones.

You are to write a program that lets two players play Go. The program should draw a board on the screen. The players can then use a mouse to play a stone - if a player clicks on an empty position in the board, the program should add a stone (black or white, according to whose turn it is) at that position, and change the turn. If the player clicks on a position that contains a stone, the program should remove the stone from that position. The program does not have to enforce any rules beyond this.

  • If you are using a computer in a lab, you can run the GoGame demo to see what your program should do (look in the assigMakeup2-demos folder).
  • Or, you can watch the demo video.

The program should have fields, a setupGUI method, a doMouse method, and a redraw method. You may have additional methods if you wish.

The program will need a field containing a 2D array to remember the current state of the board (it will be easiest to store Color.white,, or null at each element) and a field to store whose turn it is (again, storing Color.white or will make things easiest).

The setupGUI method will need to set up a button to restart the game, and make the program respond to the mouse.

The doMouse method will need to determine the row and column where the user clicked, and either add a new stone (of the current turn) to the position, if it is empty, and change the turn; or remove the stone at the position if it is not empty. It should then redraw the board. It will be easiest to have a separate redraw method to redraw the board.

This program is quite small - smaller than some of the exercises. However, the template is fairly empty, so you will need to write almost all of the program yourself. You may want to use some of the exercise programs as a model.

The correct Go board is an 18 x 18 grid of squares, and the stones are played at the intersections, as in the demo. It may be easier to draw a 19 x 19 grid of squares and play the stones in the middle of the squares.

What your program must do:
Draw a Go board (you may use the simpler version of a 19 x 19 grid of squares if you wish), and let the players place the stones on the board in alternating turns. Allow the players to remove stones by clicking on them (without changing the turn). Show whose turn it is, eg by drawing a black or white stone in the corner of the window.