package lab4;

import java.util.Scanner;

/**
   This program runs a TicTacToe game. It prompts the
   user to set positions on the board and prints out the
   result.
*/
public class TicTacToeRunner
{
   public static void main(String[] args)
   {
      Scanner in = new Scanner(System.in);
      String player = "x";
      String winner = null;
      TicTacToe game = new TicTacToe();
      boolean done = false;
      while (!done)
      {
         System.out.print(game.toString());
         System.out.print("Row for " + player + " (-1 to exit): ");
         int row = in.nextInt();
         if (row < 0)
        	 done = true;
         else
         {
            System.out.print("Column for " + player + ": ");
            int column = in.nextInt();
            game.set(row, column, player);

            winner = game.getWinner();

            if(!winner.equals(" "))
            	done = true;

            if (player.equals("x"))
               player = "o";
            else
               player = "x";
         }
      }
      if(winner.equals("x"))
     	System.out.print("x are winner");
      else if(game.getWinner() == "o")
      	System.out.print("o are winner");
      else
        System.out.print("no winner");

   }
}