i've never been this frustrated in my life. cant even do the basics here.. just need to make a simple tic tac toe program. i feel so alone in this world right now.. i get the basic idea, but can't put it together logically.
Class instance variables:
- private char[][] board; private char
- player; // 'X' or 'O'
Methods:
- public TicTacToe()
- public void print()
- public boolean play(String s)
- public boolean won()
- public boolean stalemate()
Here's what i've got for code:
import java.util.Scanner;
public class Six1
{
public static void main(String[] args)
{
TicTacToe ttt = new TicTacToe();
ttt.TicTacToe();
ttt.print();
}
static class TicTacToe
{
private char player; // 'X' or 'O'
private char[][] board;
// make board
public TicTacToe()
{
// construct board
board = new char[3][3];
// initialize elements
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
board[i][j] = ' ' ;
}
}
}
// print board
public void print()
{
for ( int i = 0; i < 3; i++)
{
System.out.println(" ");
for( int j = 0; j < 3; j++)
{
System.out.print(board[i][j] + " ");
}
System.out.println("\n------");
}
}
}
}