Goal Writing a first program in Java with a standard procedural structure. Use Git version control properly to store this project. Perform unit testing via JUnit to establish correctness of portions...

please follow the instruction in the file 'Assignment' and the use the code in 'TicTacToe'


Goal Writing a first program in Java with a standard procedural structure. Use Git version control properly to store this project. Perform unit testing via JUnit to establish correctness of portions of the assignment code created. Technology Java 16, Git, JUnit 5 Description You are going to complete a Java program which plays a Tic Tac Toe game. This game will be procedurally designed (no classes and objects and completely within one TicTacToe.java file). This game must use the exact function names requested in this assignment document. Your job will be to complete these functions and then combine them to create a Tic Tac Toe game that uses these functions. While you are creating this game you will also be tasked with creating unit tests for these functions using JUnit 5. The game of X’s and O’s, Tic Tac Toe, or Noughts and Crosses has many different names. Two players are given a square array of size 3 and take turns entering their symbol into the grid. The first one to 3 in a row (across, down, or diagonal) is the winner. this game is a solved game. That is, there is a known strategy such that a ‘perfect’ player can never lose the game. Two ‘perfect’ opposing players will always play to a draw in the game as well. We will be implementing a flexible version of the game. The user will be able to play the base game on a 3 by 3 grid but will also have the option to play with row and column combinations selected from the sizes of 3, 4, or 5. For example, boards can be 3 by 5, 4 by 3, or even 5 by 5 in size. A starter TicTacToe.java file will be provided with code to handle some of the requirements. This code should not be changed unless communication with instructor clearly approves a change. There are about 12 different functions requiring completion for the Tic Tac Toe game to operate correctly. Your job will be to complete the implementation of TicTacToe.java by implementing each of its methods to specifications indicated in the assignment. You will then need to create a TicTacToeTest.java JUnit 5 file to test these completed functions. You will also be expected to comment. Do not change the existing portions of the code. If you attempt the bonus, create a new TicTacToeBonus.java file and TicTacToeBonusTest.java file, in addition to the files for the nonbonus version. If you break your non-bonus program while doing the bonus, then you will lose those marks. YOU SHOULD NOT IMPORT ANY OTHER LIBRARIES FOR THIS ASSIGNMENT and you will get not credit for code copied from other places (cited code will get a grade of 0 as you are required to complete the required functions yourself). Example Tic-Tac-Toe Boards. (MxN -> M is rows, N is columns) EMPTY = 0, X = 1, O = 2 4x5 – win \ diagonal for O 3x3 full board 3x3 – start of game 4x4 – game undecided 4x3 – win in row 1 for X 0 0 0 1 1 1 0 2 0 0 0 2 0 0 0 0 1 1 0 1 0 2 0 0 0 0 2 0 Program Coding Requirement: The 11 functions you need to complete are as follows (all must be public static functions). I recommend first going through an creating all 11 function definitions (you don’t need to finish the inside of any immediately). You can either Javadoc comment \** *\ the functions as you make them, or do this later. Remember to inline \\ comment your functions as well. At the same time, don’t forget to add your name and student info to the TicTacToe.java file for your TA. These all have marks in the grading rubric. (Note when we say integer, we will mean the primitive type int for this assignment.) Function Name: createBoard Parameters: rows: integer, columns: integer Return: 2D integer array Assume rows/columns are valid positive integers in inclusive range [3,5]. Create and return a 2D integer array for the board of the game. Filled with EMPTY = 0 pieces. Rows should be size of first dimension of array, columns the second dimension. Function Name: rowsIn 2 1 1 2 1 2 1 2 2 2 0 1 0 0 0 2 0 1 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Parameters: board: 2D integer array Return: integer Assume board is valid 2D int array. Take in a board and return integer number of rows that board has (the size of first dimension of the array). Function Name: columnsIn Parameters: board: 2D integer array Return: integer Assume board is valid 2D int array. Take in a board and return integer number of columns that board has (the size of second dimension of the array). Function Name: canPlay Parameters: board: 2D integer array, row: integer, column: integer Return: boolean Assume board is valid 2D int array and row/column are valid indices in the board. Return boolean True if the location in the board at the indicated row/column index is open (EMPTY). Function Name: play Parameters: board: 2D integer array, row: integer, column: integer, piece: integer Return: nothing (void) Assume board is valid 2D int array, row/column are valid indices in the board, piece is X==1/O==2. Assume location (row, column) is EMPTY in the board. Play, by assigning piece, in the location in the board at the indicated row/column. Function Name: full Parameters: board: 2D integer array Return: boolean Assume board is valid 2D int array. Return true if board is filled with pieces that are all not EMPTY. Otherwise, false. Function Name: winInRow Parameters: board: 2D integer array, row: integer, piece: integer Return: boolean Assume board is valid 2D int array, row is valid index in the board, piece is X==1/O==2 Look at indicated row at given index in board. If that row has at least 3 consecutive entries with given type of piece (X/O) (3 in a row XXX, OOO), then return true, otherwise false. Function Name: winInColumn Parameters: board: 2D integer array, column: integer, piece: integer Return: boolean Assume board is valid 2D int array, column is valid index in the board, piece is X==1/O==2 Look at indicated column at given index in board. If that column has at least 3 consecutive entries with given type of piece (X/O) (3 in a row XXX, OOO), then return true, otherwise false. Function Name: winInDiagonalBS Parameters: board: 2D integer array, piece: integer Return: boolean Assume board is valid 2D int array, piece is X==1/O==2. Look at all backward slash \ diagonals in the board. If any backward slash \ diagonals has at least 3 consecutive entries with given type of piece (X/O) (3 in a row XXX, OOO), then return true, otherwise false. Function Name: winInDiagonalFS Parameters: board: 2D integer array, piece: integer Return: boolean Assume board is valid 2D int array, piece is X==1/O==2. Look at all forward slash / diagonals in the board. If any forward slash / diagonals has at least 3 consecutive entries with given type of piece (X/O) (3 in a row XXX, OOO), then return true, otherwise false. Function Name: hint Parameters: board: 2D integer array, piece: integer Return: 1D integer array (length 2) where array stores {row,column} of hint Assume board is valid 2D int array, piece is X==1/O==2 The hint scans across each row left to right, starting at the top row working down in rows. It returns a 1D integer array {r,c} containing the first hint found for the piece given to win. It does not examine for any other hints like blocking opponent’s win, or other types of hints. The only hint returned will be the first hint found that wins the game on the next play for the player. If it does not find a hint, it returns {-1, -1}. You are required to follow this pseudo-code for the hint function: For every row board For every column in the board If we can play at this row and column Play the player’s piece If the player has won the game Remove the player’s piece from the last played location Return the row and column of hint Otherwise nobody has won game, Remove the player’s piece from the last played location Default return -1 for both row and column Unit Testing Requirement: For the second part of the assignment we will be adding in Unit Testing. This will be accomplished via JUnit5. You will be required to create and submit a TicTacToeTest.java file for JUnit5. This file will consist of unit tests written to test the above 11 functions plus the public static BigInteger factorial(int n) that is already complete in the provided starter TicTacToe.java file. So 12 different functions to test in total. For each function design 1
Feb 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here