Answered step by step
Verified Expert Solution
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 ConnectFourint int constructor, ensure it's written with good code style, then test it by writing a few lines of code in the csgame.ConnectFourTester class to make sure the constructor only throws an exception when the board size is too largetoo 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 csgame.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 csgame.ConnectFourCLI class and by using input redirection as discussed in class.package csgame;
import csgameutil.GamePhase;
import csgameutil.Token;
import csgameutil.TokenGrid;
@code ConnectFour represents a twoplayer connection game involving a twodimensional grid of
@linkplain csgameutil.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 rows and
@code cols
public ConnectFourint rows, int cols
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started