Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the ConnectFour ( int , int ) constructor, ensure it's written with good code style, then test it by writing a few lines of

Implement the ConnectFour(int, int) constructor, ensure it's written with good code style, then test it by writing a few lines of code in the cs1302.game.ConnectFourTester class to make sure the constructor only throws an exception when the board size is too large/too small. Also, your code should print out the instance variables of the ConnectFour object to make sure they are consistent with the diagrams in this document.
There are a few example test methods given in ConnectFourTester.java. However, those methods are not currently called from the main method. The provided tests are meant to test the full gameplay which requires all methods to be implemented. We will revisit this in a later step below.
Implement the getRows() and getCols() methods, ensure they are written with good code style, then test them by adding test code to the cs1302.game.ConnectFourTester class in a manner that is consistent with your constructor test code. You will want to, at a minimum, print out the return value from valid calls to getRows and getCols along with the instance variables from the ConnectFour object to make sure they are consistent.
Repeat this process to implement, check code style, and test the remaining methods in the order that they appear in the ConnectFour.java starter code.
As mentioned in the comments in ConnectFourTester.java, the provided tests do not cover all of the input scenarios that need to be tested. You should add methods to test additional scenarios. Please note that you can also test your code using the cs1302.game.ConnectFourCLI class and by using input redirection as discussed in class.package cs1302.game;
import cs1302.gameutil.GamePhase;
import cs1302.gameutil.Token;
import cs1302.gameutil.TokenGrid;
??****
{@code ConnectFour} represents a two-player connection game involving a two-dimensional grid of
{@linkplain cs1302.gameutil.Token tokens}. When a {@code ConnectFour} game object is
constructed, several instance variables representing the game's state are initialized and
subsequently accessible, either directly or indirectly, via "getter" methods. Over time, the
values assigned to these instance variables should change so that they always reflect the
latest information about the state of the game. Most of these changes are described in the
project's .
*/
public class ConnectFour {
// INSTANCE VARIABLES: You should NOT modify the instance variable declarations below.
// You should also NOT add any additional instance variables. Static variables should
// also NOT be added.
be initialized by this constructor as described in the project's
.
**
@param rows the number of grid rows
@param cols the number of grid columns
@throws IllegalArgumentException if the value supplied for {@code rows} or {@code cols} is
not supported. The following values are supported: {@code 6= rows =9} and
,{@code 7= cols =9}.
*/
public ConnectFour(int rows, int cols){
image text in transcribed

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

More Books

Students also viewed these Databases questions

Question

Discuss the ethics of workplace romance.

Answered: 1 week ago