CS 364 - Final Exam, Spring 2009
This is a take home final exam and is due on Friday May 9 by 5:00PM. A printout should be in my mailbox or under my door by that time and the there should be a folder directly under your student folder named FinalExam. I should be able to double click on a run.bat file in that folder to execute your final exam project.
Requirements
In this project you are going to implement a tic-tac-toe game using Swing and multithreading. In the game the computer will be one player and the user the other.
-
Your tic-tac-toe game and interface should be thought out and
visually appealing.
For example
the 9 squares should be laid out in a grid with Xs and Os filling in the entire
square. Use nice fonts.
-
You should initially allow the user the choice of being X or O.
-
The game should allow the user to play multiple times and also keep track of
wins losses and ties.
-
There should be appropriate buttons for playing another game
and, quitting, and starting a game.
-
The first game starts by having the user make the first move in
the first game and then alternating for subsequent games.
The computer takes a turn by having the user click a
button named computer.
-
The user takes a turn by clicking on an appropriate unoccupied square.
The user should not be able to play out of turn or click on a square while
it is the computer's turn.
- When the computer has played its turn a clock should start
and display the number of seconds and tenths of second until the user
has played its turn. The clock should keep updating until the user makes
their move at which point it pauses until the computer has made its move.
When it is the user's turn again the time starts from where it left off.
-
When it is the computer's move it should pause a random
amount between 2 and 5 seconds simulating that it is thinking.
During this time the user should not be able to click on a square
out of turn.
-
The clock resets at the end of a game.
Grading
-
Your program should make appropriate use of classes. For example it is
better to use listener classes rather than having a JPanel
implement the listener class.
-
Your should use a thread for the timer.
The timer should be handled by a separate thread that is running
outside of the main the Swing thread but communicates with
the Swing thread to update the
time.
-
You may use any materials you wish for this project but you must
cite all sources and you must not copy any existing solution.
You may not communicate with anyone about this project
except for the instructor. This work must be entirely your own.
That is, academic honesty and integrity
is in place.