CSci 2101 Lab 13. May 3.
30 points
Due Friday, May 6th.
Work in pairs on this lab.
Implementing a game of Tic-Tac-Toe as a Java GUI
Use Java GUI to implement a game of Tic-Tac-Toe: the user clicks on squares,
the computer responds with a random move. Ideally when someone wins, there
should be some message displayed. Illegal moves (clicking on a square
already taken) should not be allowed. Ideally an error message should be
displayed in the GUI.
Implementation suggestions:
Make sure you follow
the Model-View-Controller
(MVC) approach.
-
In the model use 2-dimensional array to keep track of which squares
have marks on them.
- Use appropriate Java elements for your view and choose a good
layout. Run your program often (after every change).
- Use listeners as the controller part. You need to define one
class that extends
ActionListener, associate a new instance of the listener with
every button, and make sure that you pass information to the
constructor that tells the listener which button it is associated
with.
- Note that you cannot use JUnit for testing graphical
components.
Your GUI should compile, run, and implement the basic
functionality (including determining the winner).
How to submit
Submit
the java file(s) with your testing code by e-mail to me. The subject of the message
must
be 2101 Lab 13. Make
sure to CC your group partner(s).
CSci 2101 course web site.