CS 1713 Introduction to Computer Science:
Tic Tac Toe Application - take 3
In this activity you will use a completed version of the
Tic Tac Toe Application from last time to modify Case Study
15 to include a GUI.
This will be a team programming exercise.
Two or more students will work together, each creating a separate project.
At certain points you will stop and make sure your partner has gotten up
to that point.
If not, you must help your partner reach that point before continuing on.
- Get a copy of ttt1Done.zip and load it into eclipse.
You can find it on the Y: drive in the zips directory.
- Look this over and make sure you understand it.
- Make sure this runs and produces a frame in which you can play Tic Tac Toe.
Stop and make sure your partners have reached this point before continuing.
- Get a copy of Case Study 15. You can find it on the Y: drive in the
zips directory.
- Look it over and make sure you understand it.
- Make sure this runs and you can play Tic Tac Toe with it.
The main method is in GameDriver.java.
Stop and make sure your partners have reached this point before continuing.
- Rename the Case Study 15 project from cs15 to cs18 and make sure
it still runs.
- In cs18, make a new class called UserGUI in the package
tictactoe.
This class will
implement UserInterface.
The constructor will have two
parameters, a GameInterface and a boardSize and will
store the parameters in attributes.
- Make dummy methods for the unimplemented methods.
The easiest way
to do this is the hover the mouse over the underlined UserGui
and choose Add unimplemented methods.
- Modify GameDriver so that instead of each UserScanner
it does new UserGUI(game,3);
- Cut and paste the contents of the main method of the completed
TTTPanelTest into the contstuctor of UserGui
- Add a call to game.joinGame at the end of the constructor.
- Cut and paste the initialize method into UserGui.
Remove the static modifier. Make attributes for board
and tttPanel.
- Cut and paste the TicTacToePanel inner class into UserGUI.
Remove the static modifier.
Remove any extraneous imports that were inserted while doing the cut
and paste.
- If you try to run the program at this point there should be only one
compile error.
Stop and make sure your partners have reached this point before continuing.
- Fix the one compile error.
- Run the program. It should bring up two frames, one for X and one for O.
The 2 frames will be in the same place, so you will need to move one of
them aside.
Stop and make sure your partners have reached this point before continuing.
- Modify setId of UserGUI so that it calls setId of
TicTacToePanel.
- In setId of UserGUI, if the parameter is 'O',
move the window to position (400,0).
- Modify inform of UserGUI so that it calls inform
of TicTacToePanel.
- Have boardChanged of UserGUI call the corresponding
method of TicTacToePanel.
- You should not have a working program.
Stop and make sure your partners have reached this point before continuing.
- Modify the program to fix the messages on the bottom label.