Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.33 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Random;
  3.  
  4. public class CW48 {
  5. public static void main(String[] Args) {
  6. String dumboi;
  7. boolean game = true;
  8. Random r = new Random();
  9. Random c = new Random();
  10. Scanner in = new Scanner(System.in);
  11. int comp = 0;
  12. String[][] table = { { "_", "_", "_" }, { "_", "_", "_" }, { "_", "_", "_" }, };
  13. System.out.println("_ _ _");
  14. System.out.println("_ _ _");
  15. System.out.println("_ _ _");
  16. System.out.println("Welcome to tic tac toe");
  17. System.out.println("Enter your name: ");
  18. dumboi = in.nextLine();
  19. System.out.println("Enter the row: ");
  20. int x = in.nextInt();
  21. System.out.println("Enter the column: ");
  22. int y = in.nextInt();
  23. table[x][y] = "x";
  24. x = r.nextInt(3);
  25. y = r.nextInt(3);
  26. table[x][y] = "O";
  27. System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
  28. System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
  29. System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
  30. System.out.println("Enter the row: ");
  31. int z = in.nextInt();
  32. System.out.println("Enter the column: ");
  33. int w = in.nextInt();
  34. table[z][w] = "x";
  35. z = r.nextInt(3);
  36. w = r.nextInt(3);
  37. table[z][w] = "O";
  38. System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
  39. System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
  40. System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
  41. System.out.println("Enter the row: ");
  42. int a = in.nextInt();
  43. System.out.println("Enter the column: ");
  44. int b = in.nextInt();
  45. table[a][b] = "x";
  46. a = r.nextInt(3);
  47. b = r.nextInt(3);
  48. table[a][b] = "O";
  49. System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
  50. System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
  51. System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
  52. System.out.println("Enter the row: ");
  53. int e = in.nextInt();
  54. System.out.println("Enter the column: ");
  55. int d = in.nextInt();
  56. table[e][d] = "x";
  57. e = r.nextInt(3);
  58. d = r.nextInt(3);
  59. table[e][d] = "O";
  60. System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
  61. System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
  62. System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement