• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

any advice?

 
jesse johnson
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have no idea where to go with this:
public class TicTacToe {
private String board[][] = new String[3][3];
private String X = " X ";
private String O = " O ";
private String blank = " ";

//constructor - defaults to an empty board of 3x3 positions
public TicTacToe();
for (int i = 0; i< board.length; i++)
for (int j = 0; j < board[i].length; j++)
board[i][j] = blank;

//attempts to mark a position for the player. returns
//false if position is already taken
private boolean move (int player, int position);
//asks user for position. use and validate 1 - 9;
//1 2 3
//4 5 6
//7 8 9
//make sure move is valid
private int getMove();
//returns the following:
//0 - no winner yet; 1 - player 1 wins; 2 - player 2 wins; 3 - tie game
private int checkWinner();
//display board
private void displayBoard();
//contains the logic for playing the game. sets up general play action of:
//display board
//asks player 1 to move
//check for winner
//display board
//ask player 2 to move
//check for winner
//repeat steps until winner or tie.
public void play();

public static void main (string args []) {
}
 
Barry Andrews
Ranch Hand
Posts: 528
C++ Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Noone else knows where to go either because you did not ask a question. What specifically are you trying to do? I doubt if anyone here is going to write your program for you.
Barry
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got something here. It uses more classes (which is a good thing) than you have, it isn't complete and I didn't try and compile it. And of course the code goes into 3 different files. Let me know if you have any questions about it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic