Create a TicTacToe that will enable you to write a program to play Tic-Tac-Toe. The class contains a private 3-by-3 2 dimensional arrays. Use an enumeration to represent the values in each square of the array. The enumeration's constants should be named X, 0 and EMPTY (for a position that doesn't contain an X or 0).
The constructor should initialize the board elements to EMPTY. Allow 2 human players. Wherever the first player moves place an X in the specified square amd place an 0 wherever the second player moves. Each move must be to an empty square. After each move, determine whether the game has been won and whether it's a draw.
Jason Attin wrote:I have a few questions:
1) what type should the array have? I mean it will get values like "X", "O" and "EMPTY", so is it ok for it to be a string?
2)enumeration: I am meant to use an enumeration, but can I use it within a class or should it be on its own file?
?) i would have thought I will create an array of type TicTacToeEn:use a three‑element enum, with EMPTY or similar as a value.
because I don't seem to be able to come up with a way to get the square number without an awful amount of code. If I 'number' the squares with numbers from 1 to 9 it seems really complicated to associate a number to the position, eg suqare 1 being boards[0][0], so I think, for now, I will stick to one method and see how it goes, I will post back as soon as I complete the codecreate isInWinningRow() and isInWinningDiagonal() methods,