Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ackage cs 1 3 0 2 . game; 2 3 import cs 1 3 0 2 . gameutil.GamePhase; 4 import cs 1 3 0 2

ackage cs1302.game;
2
3 import cs1302.gameutil.GamePhase;
4 import cs1302.gameutil.Token;
5 import cs1302.gameutil.TokenGrid;
6
7/**
8*{@code ConnectFour} represents a two-player connection game involving a two-dimensional grid\
of
9*{@linkplain cs1302.gameutil.Token tokens}. When a {@code ConnectFour} game object is
10* constructed, several instance variables representing the game's state are initialized and
11* subsequently accessible, either directly or indirectly, via "getter" methods. Over time, the
12* values assigned to these instance variables should change so that they always reflect the
13* latest information about the state of the game. Most of these changes are described in the
14* project's
15* functional requirements.
16*/
17 public class ConnectFour {
18
19//-----------------------------------------------------------------------------------------\
-----
20// INSTANCE VARIABLES: You should NOT modify the instance variable declarations below.
21// You should also NOT add any additional instance variables. Static variables should
22// also NOT be added.
23//-----------------------------------------------------------------------------------------\
-----
24
25 private int rows; // number of grid rows
26 private int cols; // number of grid columns
27 private Token[][] grid; //2D array of tokens in the grid
28 private Token[] player; //1D array of player tokens (length 2)
29 private int numDropped; // number of tokens dropped so far
30 private int lastDropRow; // row index of the most recent drop
31 private int lastDropCol; // column index of the most recent drop
32 private GamePhase phase; // current game phase
33
34//-----------------------------------------------------------------------------------------\
-----
35// CONSTRUCTOR
36//-----------------------------------------------------------------------------------------\
-----
37
38/**
39* Constructs a {@link cs1302.game.ConnectFour} game with a grid that has {@code rows}-many
40* rows and {@code cols}-many columns. All of the game's instance variables are expected to
41* be initialized by this constructor as described in the project's
42* functiona\
l
43* requirements.
44*
45* @param rows the number of grid rows
-UU-:--- F1 ConnectFour.java Top (1,0) Git-main (Java//l ws Abbrev)---------------------

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

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

4. Are there any disadvantages?

Answered: 1 week ago

Question

3. What are the main benefits of using more information technology?

Answered: 1 week ago

Question

start to review and develop your employability skills

Answered: 1 week ago