
/**
 *
 * Noughts and Crosses class
 *
 * Written by: Roger Garside
 *
 * First Written: 18/Oct/96
 * Last Rewritten: 18/Oct/96
 *
 */

public class Noughts
    {
    public static final int BLANK = 0 ;
    public static final int NOUGHT = 1 ;
    public static final int CROSS = 2 ;

    private int[][] board = new int[3][3] ;

    public Noughts()
	{
	for (int i = 0 ; i < 3 ; i++)
	    for (int j = 0 ; j < 3 ; j++)
		board[i][j] = BLANK ;
	} // end of constructor method

    public boolean isWin()
	{
	if (((board[0][0] == board[1][1]) && (board[1][1] == board[2][2]) &&
	     (board[0][0] != BLANK)) ||
	    ((board[0][2] == board[1][1]) && (board[1][1] == board[2][0]) &&
	     (board[0][2] != BLANK)) ||
	    ((board[0][0] == board[0][1]) && (board[0][1] == board[0][2]) &&
	     (board[0][0] != BLANK)) ||
	    ((board[1][0] == board[1][1]) && (board[1][1] == board[1][2]) &&
	     (board[1][0] != BLANK)) ||
	    ((board[2][0] == board[2][1]) && (board[2][1] == board[2][2]) &&
	     (board[2][0] != BLANK)) ||
	    ((board[0][0] == board[1][0]) && (board[1][0] == board[2][0]) &&
	     (board[0][0] != BLANK)) ||
	    ((board[0][1] == board[1][1]) && (board[1][1] == board[2][1]) &&
	     (board[0][1] != BLANK)) ||
	    ((board[0][2] == board[1][2]) && (board[1][2] == board[2][2]) &&
	     (board[0][2] != BLANK)))
	    return true ;
        else
	    return false ;
	}

    public static void main(String[] args)
	{
	Noughts b1 = new Noughts() ;

	if (b1.isWin())
	    System.out.println("immediate win") ;
	else
	    System.out.println("not immediate win") ;
	} // end of main method

    } // end of class Noughts

