Advertisement
gsmplustea

tictactoe

Jul 16th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. package bryanluzada;
  2. import java.util.*;
  3. public class BryanLuzada {
  4.  
  5. public static void main(String[] args) {
  6. Scanner bl = new Scanner(System.in);
  7. int moveB = 0;
  8. int moveL = 0;
  9. String tic [] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",};
  10.  
  11. int x = 0;
  12. while(x != 1)
  13. {
  14.  
  15. moveB = bl.nextInt();
  16. tic[moveB] = "X";
  17. if(tic[moveB].equals(tic[moveL]))
  18. {
  19. System.out.println("The spot has been taken by the opponent!");
  20. }
  21. else
  22. {
  23. printTic(tic);
  24. }
  25.  
  26. moveL = bl.nextInt();
  27. tic[moveL] = "O";
  28. if(tic[moveL].equals(tic[moveB]))
  29. {
  30. System.out.println("The spot has been taken by the opponent!");
  31. }
  32. else
  33. {
  34. printTic(tic);
  35. }
  36.  
  37. }
  38. }
  39. public static void printTic(String tic[])
  40. {
  41. System.out.println(tic[1] + " " + tic[2] + " " + tic[3]);
  42. System.out.println(tic[4] + " " + tic[5] + " " + tic[6]);
  43. System.out.println(tic[7] + " " + tic[8] + " " + tic[9]);
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement