Question

Can you please solve the following lab question in java..

Image transcriptions

UNIVERSITY af U'F FLORIDA Herbert Werthe'rm College of Engineering COP3502 Lab 05: Connect-Four Overview This lab is designed to introduce students to 2—D arrays by recreating one of everyone's favorite childhood games: Connect—Four. You will loop through arrays, and manipulate them. Your end product should be robust enough to not have a single ArrayIndexOutOfBounds Exception! Specification You will ﬁrst start by asking the user for what they wish the height and length of the board to be: what would you like the height of the board to be? 4 what would you like the length of the board to be? 5 Then you will print the empty board: And tell the player's what their tokens are: Player 1: x Player 2: o The players will take turns placing their tokens by choosing columns. .. Player 1: which column would you like to choose? 9 _..until one of them wins! Player 1: which column would you like to choose? 6 x _ _ _ _ x _ _ _ _ x - o - -

X 0 X D 0 Player 1 won the game! Or until there is a tie! Player 2: which column would you like to choose? 2 O X 0 X D X 0 0 X X X 0 O O X xnxox Draw. Nobody wins . Elements in the array should be accessible Via row-major indexing (hoard[row][column]). In addition, the data should be stored so that row zero is the bottom of the board, i.e.: Rows x-»-- R0112 x—--- Rowl x-o-- Rowe xoxoo Make sure you test this along the way! Otherwise, your method tests in ZyBooks will fail! Assumptions Students can assume that: - the user will choose for the board dimensions to be 4x4 or greater. - the user will input a valid column number (from 0 to length-l ), - the column that the user ehoses to place their token into has space (it is not ﬁlled already by other tokens). - players can only win vertically or horizontally, but not diagonallyl Required Methods public static void printBoard(char array) This will print the board. public static void initializesoard(char array) This will set each spot in the army to public static int insertchip(char array, int col, char chipType) Places the token in the column that the user has chosen. Will ﬁnd the next available spot in that oolumn if there are already tokens there. The row that the token is placed in is returned. public static booLean checklﬂlinnerkhar [ ] array, int col, int row, char chipType) Aﬁer a token is added, checks whether the token in this location, of the speciﬁed chip type, creates four in a row. Will return true ifsomeone won, and false otherwise. Hint: Implement the methods in this order. Submission NOTE: Your output must match the example output *exactly'. If it does not, you will not receive fill! credit for your submission! Files: ConnectFour.java Method: Submit on ZyLabs Sample Output What would you like the height of the board to be? 4 what would you like the length of the board to be? 5 Player 1: x Player 2: 0 Player 1: which column would you like to choose? 6 Player 2: which column would you like to choose? 3 Player 1: which column would you like to choose? 0 Player 2: which column would you like to choose? 1 Player 1: which column would you like to choose? 0 Player 2: which column would you like to choose? 4

X - - xo - OO Player 1: Which column would you like to choose? 2 X X - XOXOO Player 2: Which column would you like to choose? 2 X - 0 - - XOXOO Player 1: Which column would you like to choose? 0 X - - - X - X - 0 - XOXOO Player 1 won the game! Process finished with exit code 0

UNIVERSITY af U'F FLORIDA Herbert Werthe'rm College of Engineering COP3502 Lab 05: Connect-Four Overview This lab is designed to introduce students...

365,837 students got unstuck by Course
Hero in the last week