Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java Instructions You are going to write a connectBoard() method that takes a width, a height and a list of moves and builds the corresponding

java image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Instructions 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 Write the body of the program Details of connectBoard() method You will be creating a new method called connectioarall. The main method input method car 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 lwidth)the width of the board an integer height: height of the board an integer array Imovescontaining Integers in the range of 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 plece 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 place is present. Otherse, the cell will contain *** Sample input/output: Sample connect Board() Input Sample connect Board() output Resulting Board import java.util.Scanner; 9. / Problem: Connect 4 Task: write a connect Board method that takes a width, a height moves and builds the corresponding Connect board, Params: int width: width of the board int height : height of the board int moves : integers in the range 1 ... Width (inclusive) Processing: Create a width x height Connect-4 board represented by a 2D String array. Each of the integers in moves is a column where to drop the piece: 1 is the first column width is the last. Outout: String OO ! a 2D array where a cell is null if no piece is present, otherwise the cell contains the string Example: If the arguments to the function are 2 3 4 3 4 4 4 the resulting board will look like class Pon3 38. public class POD { 39 40 41 42 Takes a width, a height, and list of moves and builds the corresponding Connect-4 board, eparam width Integer width of the board * Sparam height Integer height of the board * Sparam moves array of integers, each in the range 1 ... width (inclusive) ereturn A ZD String array where a cell is null if no piece public static String CD connectBoard int width, int height, the moves ) { //Declare 2D string array to hold depiction of a width x height Connect-4 board String On board = new String[width][height]; 1/Integer array to hold count of pieces in each column into columnCount - new int[width]; 1/ PLEASE START YOUR WORK HERE //PLEASE END YOUR WORK HERE return board; 38. public class POD { 39 40 41 42 Takes a width, a height, and list of moves and builds the corresponding Connect-4 board, eparam width Integer width of the board * Sparam height Integer height of the board * Sparam moves array of integers, each in the range 1 ... width (inclusive) ereturn A ZD String array where a cell is null if no piece public static String CD connectBoard int width, int height, the moves ) { //Declare 2D string array to hold depiction of a width x height Connect-4 board String On board = new String[width][height]; 1/Integer array to hold count of pieces in each column into columnCount - new int[width]; 1/ PLEASE START YOUR WORK HERE //PLEASE END YOUR WORK HERE return board; //PLEASE END YOUR WORK HERE return board; public static void main(String args) { Scanner in - new Scanner(System.in); int width = in.nextInt(); int height = in.nextInt(); int numberOf Moves - in.nextInt(); //Declare and initialize the moves array into moves = new int[numberOfMoves); for (int i=0; i

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Understand the basic theories and concepts of OD

Answered: 1 week ago

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago