Docsity

Solved Programming Assignment 6 - Data Structure and Algorithm | CS 303, Assignments of Computer Science

Toggle sidebar
bg1
CS 303L Data Structure and Algorithm
April 9, 2008
Programming Assignment 6
(Due on April 24, 2008)
In this assignment, we are going to implement a game, Tic-Tac-Toe, using the game tree you
built in class (Lab Exercise 12). A template of the Tic-Tac-Toe is provided on the course website.
The given Java Code is adopted from the following website:
http://www.dreamincode.net/forums/showtopic21423.htm
This template provides a GUI for playing the Tic-Tac-Toe with two players. Your task is
introducing the game tree in the template such that computer can simulate one of the players
and play the game with you. More specifically, you should make computer to decide its best
movement based on the game tree.
The structure of the given template is shown as follows:
public TicTacToe()
{ … This is the constructor of the TicTacToe class for creating the GUI … }
public void actionPerformed(ActionEvent e)
{
… // Get input from users
… // Check whether any user wins the game
}
public static void main(String[] args)
{ … The main method for creating an instance of TicTacToe … }
For this assignment, you just need to change the actionPerformed() method such that the
structure following method takes input from both users and check if any user wins the game.
(Two-page report is required)

Partial preview of the text

Download Solved Programming Assignment 6 - Data Structure and Algorithm | CS 303 and more Assignments Computer Science in PDF only on Docsity!

CS 303L Data Structure and Algorithm

April 9, 2008

Programming Assignment 6

(Due on April 24, 2008)

In this assignment, we are going to implement a game, Tic-Tac-Toe, using the game tree you built in class (Lab Exercise 12). A template of the Tic-Tac-Toe is provided on the course website. The given Java Code is adopted from the following website:

http://www.dreamincode.net/forums/showtopic21423.htm

This template provides a GUI for playing the Tic-Tac-Toe with two players. Your task is introducing the game tree in the template such that computer can simulate one of the players and play the game with you. More specifically, you should make computer to decide its best movement based on the game tree.

The structure of the given template is shown as follows:

public TicTacToe() { … This is the constructor of the TicTacToe class for creating the GUI … }

public void actionPerformed(ActionEvent e) { … // Get input from users … // Check whether any user wins the game }

public static void main(String[] args) { … The main method for creating an instance of TicTacToe … }

For this assignment, you just need to change the actionPerformed() method such that the structure following method takes input from both users and check if any user wins the game.

( Two-page report is required)