• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

any advice?  RSS feed

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 []) {
Ranch Hand
Posts: 529
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.
Ranch Hand
Posts: 1067
IntelliJ IDE Java Spring
  • 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.
I love a woman who dresses in stainless steel ... and carries tiny ads:
how do I do my own kindle-like thing - without amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!