Tic Tac Toe design

Two dimensional array

Page 1 of 1

2 Replies - 19237 Views - Last Post: 11 March 2010 - 07:22 PM Rate Topic: -----

#1 pp_beezy   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 11-March 10

Tic Tac Toe design

Posted 11 March 2010 - 04:07 PM

Using NetBeans design the UML for both of the following classes:
TicTacToe and TicTacToeGame.
The TicTacToe class contains a 3x3 two-dimensional array of integers. The constructor should initialize the empty board to all zeros. It should have a method playerMove that accepts two integers as parameters, the first is the player (1 or 2) and the second is the actual move (1-9). If it is a valid move it changes the value of that square to 1 or 2 (depending on whose turn it is and returns the Boolean value true to indicate a valid move has been completed). If it is not a valid move the board does not change and it returns a Boolean value of false to indicate an invalid move. TicTacToe should also have the method displayBoard that will display the current state of the board. The last method should be determineWinner which returns a 1 if player one won, a 2 if player 2 won, a 0 if it’s a ‘cat’s game’, and -1 if there is no winner yet and the game is not over.
TicTacToeGame is another program that uses a TicTacToe object to actually play a two human player game of Tic-Tac-Toe. Using the NetBeans design tool also create a sequence diagram for this game.

Is This A Good Question/Topic? 0
  • +

Replies To: Tic Tac Toe design

#2 m-e-g-a-z   User is offline

  • Winning
  • member icon

Reputation: 497
  • View blog
  • Posts: 1,457
  • Joined: 19-October 09

Re: Tic Tac Toe design

Posted 11 March 2010 - 04:16 PM

As this is related to UML and this is a java programming section for programming issues, wouldnt it be better if you had posted this in a different section such as computer science?

Anyways Class Diagrams are laid out like this

Class name e.g
Variables Section e.g
size : int
height : int
Methods Section e.g

Which are obviously linked up to other classes. This is just showing you a single class and its class name, attributes field and methods field.

Have a look at this tutorial for more help

UML Help

This post has been edited by m-e-g-a-z: 12 March 2010 - 03:07 AM

Was This Post Helpful? 0
  • +
  • -

#3 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2965
  • View blog
  • Posts: 11,222
  • Joined: 15-July 08

Re: Tic Tac Toe design

Posted 11 March 2010 - 07:22 PM

And "Java" is a REALLY bad name for a forum dedicated to java programs...Next time, be more thoughtful about your name. In general, it is the best way to get an expert to even look at your post in 30 characters or less. See what I named yours?

Also, if you want, I wrote a tutorial on Tic Tac Toe. I hope you find it useful! :)

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1