Hey need to create tic tac toe but which reads from tester file - after the right direction to go from here, on how to implement it

import java.util.*;

public class TicTacToe
{
    public TicTacToe()
    {
            Scanner input = new Scanner(System.in);
                                  
            char[][] board = new char[3][3];             // Sets up game board
            final int totalturns = 9;                    // Initiaqlizes total amount of turns
            
            newBoard(board);
            print(board);
    }
    
    public static void print (String args[]) 
    {

    }
    
    private static void newBoard(char[][] board)
    {
        for (int row = 0; row < board.length; row++)
        {
            for (int col = 0; col < board[0].length; col++)
            {
                board[row][col] = '-';
            }
        }
    }
        
    private static void print(char[][] board)
    {
        for (int row = 0; row < board.length; row++)
        {
            for (int col = 0; col < board[0].length; col++)
            {
                System.out.print(board[row][col]);
            }
        }
    }      
   }

I am not shure what you mean but here is how you read from a file

first creat a scanner for the file

Scanner [B]input[/B] = new Scanner(new File([B]Name of file here[/B]));

then read from the file

[B]input.next();[/B]

you are going to want to put the "read from file code" inside an if statement that checks wether or not there is anything left to read like this

if(input.hasNext()){

}

in bluejay you have a tester file, so in there is a an array to input into the gameboard

so you would have the moves already set up and say with each new row of reading i would have to implemeent that it it check if there a winner, whos go etc..


but for now just need to know how to implement the moves part

so you want to know how to write to your array and tell the players whos turn it is as well as print the result?

I still don't know what you mean by a tester file you will have to describe it a little. (:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.