Question: You just need to code after the comment ' Please start your code'. All the rest of code has been given. You are going to




You just need to code after the comment ' Please start your code'. All the rest of code has been given.
You are going to write a connectBoard() method that takes a width, a height and a list of moves and builds the corresponding Connect-4 board. Not familiar with the game? Read this! Write the body of the program. Details of connectBoard() method You will be creating a new method called connectBoard). The main method input method call and output have been taken care of for you. Details of your new method are below: Input: Parameters The connectBoard() method will take the following parameters: an integer (width): the width of the board an integer (height]: height of the board an integer array (moves): containing integers in the range of 1 to width (inclusive) Processing Create a width x height Connect-4 board represented by a 2D string array. Each of the integers in moves is gives the column where a piece is "dropped": 1 is the first column (from left to right) width is the last. Output: Return value The connectBoard() will output a 2D string array where a cell is null if no piece is present. Otherse, the cell will contain ***, Sample input/output: Sample input/output: Sample connectBoard () input Sample connectBoard () output Resulting Board * {"*", , , * * , "*", "*" {"*", {"*" }, "*" * * {"*" * * 1 3 2 3 1 1 4 1 3 4 SI * 1 1 * " * " " * *" ** } ** public class POD { * Takes a width, a height, and list of moves and builds the corresponding Connect-4 board, * @param width Integer width of the board * @param height Integer height of the board * @param moves Array of integers, each in the range 1 ... width (inclusive) * @return A 2D String array where a cell is null if no piece public static String[] [] connectBoard int width, int height, int[] moves ) { //Declare 2D string array to hold depiction of a width x height Connect-4 board String[] [] board = new String[width][height]; //Integer array to hold count of pieces in each column int[] column Count = new int[width]; // PLEASE START YOUR WORK HERE //PLEASE END YOUR WORK HERE return board; public static void main( String [] args) { Scanner in = new Scanner( System.in); 'int width = in.nextInto; int height = in.nextInto; int numberOfMoves = in.nextInt(); //Declare and initialize the moves array intri moves = new int[numberOfMoves); for (int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
