Hi I am creating a 10×10 Board game in JAVA where who ever gets four Xs in a row wins the game. I was able to make

Hi I am creating a 10×10 Board game in JAVA where who ever gets four Xs in a row wins the game. I was able to make a multi player mode, but I want make a mode where the user plays the computer. Can you please look at my code and see where I can add a program where I can play the computer?

Code:

import java.util.Scanner;

//Start of Program

public class wwalton_MultiPlayerAggieGame {

//Main Method of Program

public static void main(String[] args) {

//Welcome Message

System.out.println(“Welcome To 10×10 Multiplayer Mode”);

Scanner scnr = new Scanner(System.in);

//The Creation of Board

char[][] gridBoard = new char[10][10];

//Initializing the Array

for (int row = 0; row < gridBoard.length; row++){ for (int col = 0; col < gridBoard[0].length; col++){ gridBoard[row][col] = ' '; } } int playerTurn = 1; char player = 'X'; boolean winnerBool = false; //play a turn while (winnerBool == false && playerTurn <= 42){ boolean validTurn; int play; //do while loop created to display board then print out designated player turn. do { display(gridBoard); System.out.print("Your Turn" + " Player "+ player); play = scnr.nextInt(); //validation of play validTurn = validate(play,gridBoard); }while (validTurn == false); //drop the checker for (int row = gridBoard.length-1; row >= 0; row–){

if(gridBoard[row][play] == ‘ ‘){

gridBoard[row][play] = player;

break;

}

}

//determine if there is a winner

winnerBool = wonGame(player,gridBoard);

//switch players

if (player == ‘X’){

player = ‘X’;

}else{

player = ‘X’;

}

playerTurn++;

}

display(gridBoard);

if (winnerBool){

if (player==’X’){

System.out.println(“Player 1 WON!!!”);

}else{

System.out.println(“Player 2 WON!!!”);

}

}else{

System.out.println(“Tie game”);

}

}

public static void display(char[][] gridDisplay){

System.out.println(” 0 1 2 3 4 5 6 7 8 9″);

System.out.println(“———————“);

for (int displayRow = 0; displayRow < gridDisplay.length; displayRow++){ System.out.print("|"); for (int col = 0; col < gridDisplay[0].length; col++){ System.out.print(gridDisplay[displayRow][col]); System.out.print("|"); } System.out.println(); System.out.println("---------------------"); } System.out.println(" 0 1 2 3 4 5 6 7 8 9"); System.out.println(); } public static boolean validate(int column, char[][] gridValidation){ //valid column? if (column < 0 || column > gridValidation[0].length){

return false;

}

//full column?

if (gridValidation[0][column] != ‘ ‘){

return false;

}

return true;

}

public static boolean wonGame(char player, char[][] gridWinner){

//check for 4 across

for(int winnerRow = 0; winnerRow

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?