View Single Post
  #1 (permalink)  
Old 07-03-2007, 08:33 PM
Eric Eric is offline
Senior Member
 
Join Date: Jun 2007
Posts: 111
Eric is on a distinguished road
Help with Tic Tac Program
I have a project to create tic tac toe without a gui.
I need Assistance with writing a program.
Can anyone point me in the right direction of where to get some leads.
This is my potential Tic Tac Program without GUI; written in pseudo.

Code:
package proyect; import java.util.*; public class TicTacToeMain { private char [][] board; private boolean xturn; private int numMoves; public static void main() { Scanner keyb = new Scanner(System.in); String response; do { TicTacToeMain game = new TicTacToeMain(); play(); System.out.println("Would you like to play again?"); response = keyb.nextLine(); }while(response.equalsIgnoreCase("yes")); } public TicTacToeMain() { board = new char [5][5]; xturn = true; numMoves = 0; } public void play() { do { //show board //get valid move //update board //determine winner if possible }while((no one has won)&&(moves < 9)); } public boolean won(int row, int col)//computer indices (inside) { if(allSquaresInRowAreSame) or board[0][0] ==board[2][2]&&board[0][2]==board[0][4] return true; if(allSquaresInColAreSame) return true; return wonOnDiagonal(); } public boolean wonOnDiagonal() { if(board[0][0]==board[2][2]&&board[2][2] ==board[4][4]&&board[0][0]!=space or " ") return true; return //same on positive and not space } }

Thanks!

Eric
Reply With Quote
Sponsored Links