This assignment needs to handle NXN not just 3X3 Driver Output Problem Statement
ID: 3821354 • Letter: T
Question
This assignment needs to handle NXN not just 3X3
Driver
Output
Problem Statement You will build an application that allows a person to play tic-tac-toe against the computer. Your application will print out the board, the computer select a spot, and ask the user to select spot. This will continue until the game ends (a full row, column, or corner to corner diagonal have the same mark, or if no more moves are possible due to the lack of vacant spots). Your application will do limited error checking to ensure occupied spots won't be overwritten with new values. Finally, the board does not need to be 3x3. Your solution needs to be able to handle any Square (NxN) board. The parameter for board size is passed in the constructor Assignment Create an Outlab6 project and paste this into a Driver. You won't need to change the Driver Here are some specifications and assumptions for you: No player is allowed to mark an already marked spot. If the human tries to do that, an error message must be printed and the player is to be prompted for another spot until they enter a valid one (however many times it takes) o No player is allowed to attempt to mark a spot outside of the bounds of the board (e.g. row 0, column 7 is not allowed in a3x3 board) o The computer move method will randomly select a spot for the computer to place its mark. The spot to be marked must not already be occupied (if it is, just randomly select a new spot. Here is some sample output that needs to be fairly closely replicated (see grading).Explanation / Answer
// A java Program to play tic-tac-toe
import java.io.*;
import java.util.*;
class TicTacToe{
static final String EMPTY = "·";
// Let us assume that the Computer will move with 'O' and human with 'X'
static char final COMPUTERMOVE= 'O';
static char final HUMANMOVE= 'X';
//function to create board of given size
// A function to show the current board status
// A function to show the instructions
public static void showInstructions()
{
printf(" Tic-Tac-Toe ");
System.out.println("Choose a cell numbered from 1 to 9 as below"
" and play ");
System.out.println(" 1 | 2 | 3 ");
System.out.println(" -------------- ");
System.out.println(" 4 | 5 | 6 ");
System.out.println(" -------------- ");
System.out.println(" 7 | 8 | 9 ");
System.out.println("- - - - - - - - - - ");
return 1;
}
int n=boardlength;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.