20-CS-694 Advanced Programming Techniques Spring 2012
Homework Assignment 1

Interfaces, Exceptions, Graphics, Animation, Threads, Reflection, Networking, RMI, JDBC, JNI

Java Warm Up

Due: April 5, 2012 (submit instructions: here)

    This is a simple warm-up exercise. The results should be useful in completing your midterm exam and final project.
Homework Problem:
Write a Java applet that facilitates playing the game of Tic-Tac-Toe between two players. The applet should show the board which consists of a 3x3 matrix of JButtons and a "Start" JButton. Matrix JButtons are initially blank but may display O or X as the mouse is clicked over them during a game. Once a button displays a mark, that mark cannot be changed. A game is started by clicking the "Start" JButton. That action clears the matrix. Players alternate clicking a blank matrix JButton of their choosing. On odd turns an X will appear in a clicked JButton. On even turns an O will appear. Clicking on a non-blank JButton simply does not count for anything and the same player will continue his or her move. When a game ends when there exists a complete row, column, or diagonal containing the same mark or when this is not the case and no non-blank JButtons remain. If a game ends in the first way, a voice saying "Excellent" is heard. The applet to the right illustrates the expected result. See the homework hints for help.