Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.Random;
- public class CW48 {
- public static void main(String[] Args) {
- String dumboi;
- boolean game = true;
- Random r = new Random();
- Random c = new Random();
- Scanner in = new Scanner(System.in);
- int comp = 0;
- String[][] table = { { "_", "_", "_" }, { "_", "_", "_" }, { "_", "_", "_" }, };
- System.out.println("_ _ _");
- System.out.println("_ _ _");
- System.out.println("_ _ _");
- System.out.println("Welcome to tic tac toe");
- System.out.println("Enter your name: ");
- dumboi = in.nextLine();
- System.out.println("Enter the row: ");
- int x = in.nextInt();
- System.out.println("Enter the column: ");
- int y = in.nextInt();
- table[x][y] = "x";
- x = r.nextInt(3);
- y = r.nextInt(3);
- table[x][y] = "O";
- System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
- System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
- System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
- System.out.println("Enter the row: ");
- int z = in.nextInt();
- System.out.println("Enter the column: ");
- int w = in.nextInt();
- table[z][w] = "x";
- z = r.nextInt(3);
- w = r.nextInt(3);
- table[z][w] = "O";
- System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
- System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
- System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
- System.out.println("Enter the row: ");
- int a = in.nextInt();
- System.out.println("Enter the column: ");
- int b = in.nextInt();
- table[a][b] = "x";
- a = r.nextInt(3);
- b = r.nextInt(3);
- table[a][b] = "O";
- System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
- System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
- System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
- System.out.println("Enter the row: ");
- int e = in.nextInt();
- System.out.println("Enter the column: ");
- int d = in.nextInt();
- table[e][d] = "x";
- e = r.nextInt(3);
- d = r.nextInt(3);
- table[e][d] = "O";
- System.out.println(table[0][0] + " " + table[0][1] + " " + table[0][2]);
- System.out.println(table[1][0] + " " + table[1][1] + " " + table[1][2]);
- System.out.println(table[2][0] + " " + table[2][1] + " " + table[2][2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement