Lecture 16: In-class Exercise:   A Graphical View and Controller for Tic Tac Toe
1 A View and Controller for Tic Tac Toe
2 Testing
3 Notes to Keep in Mind
8.9

Lecture 16: In-class Exercise: A Graphical View and Controller for Tic Tac Toe

1 A View and Controller for Tic Tac Toe

The purpose of this exercise is to give you practice with implementing the View and Controller components of the Model-View-Controller design pattern, by means of a graphical user interface using Java’s Swing library.

You may work freely with other students on this exercise!

In the starter code, you are given an interface representing a controller for Tic Tac Toe, with two methods, playGame() and handleCellClick(). You are also given an interface for a view, TTTView, which is coupled to the controller interface, as it has a method addClickListener which takes a TicTacToeController as an argument. Your task is to implement the two interfaces to create an interactive, graphical Tic Tac Toe game. Put your new controller and view code in the same package alongside your Tic Tac Toe model as it will depend on the model. You are also given a class Main with a main method that will allow you to test your game interactively.

You will need to create four classes:

You will also need to fill in the parts of the main method in Main.java as noted in the comments in that method.

2 Testing

Test your view by running it, inspecting the view, clicking on the game board and playing the game. No automated tests here.

3 Notes to Keep in Mind