Advertisement
Guest User

Untitled

a guest
Jan 31st, 2013
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. This program tests the TicTacToe class by prompting the
  5. user to set positions on the board and printing out the
  6. result.
  7. */
  8. public class TicTacToeTester
  9. {
  10. public static void main(String[] args)
  11. {
  12. Scanner in = new Scanner(System.in);
  13. String player = "x";
  14. TicTacToe game = new TicTacToe();
  15. boolean done = false;
  16. while (!done)
  17. {
  18. game.getWinner();
  19. System.out.print(game.toString());
  20. System.out.print(
  21. "Row for " + player + " (-1 to exit): ");
  22. int row = in.nextInt();
  23. if (row < 0) done = true;
  24. else
  25. {
  26. System.out.print("Column for " + player + ": ");
  27. int column = in.nextInt();
  28. game.set(row, column, player);
  29. if (player.equals("x"))
  30. player = "o";
  31. else
  32. player = "x";
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement