Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Description: We are going to play a fun strategy game that only requires two players! In this game, we have an 8 8 board

Assignment Description: We are going to play a fun strategy game that only requires two
players! In this game, we have an 88 board and a Knight chess piece that starts on the top left
of the board. Each player gets to move the Knight piece one square over either down, diagonal
(bottom right direction), or to the right of its current position (a player cannot move the piece two
or more squares). The Knight piece can keep moving until it reaches the bottom right comer of
the board. The respective player that moves the Knight to the bottom right corner of the board
wins the game! In this assignment you are going to implement the winning strategy for player 1
only.
When the game begins, the knight is
on the top left square of the board.
When the game ends, the knight is on
the bottom right square of the board.
For this assignment, you must follow these requirements.
You will create a public class called Game.
The Game Class will have the following attributes:
a.2D integer array that symbolizes the board to assist you with simulating the game.
b.1D primitive character array that stores the respective moves that will be used for
player 2. Please store them in order of how they are presented here.
i.'d' for downward diagonal right direction (index 0)
ii.'r' for horizontal right direction (index 1)
iii. 'b' for vertical bottom direction (index 2)
c. A reference to a Random Class object. This will point to the object created by the
driver and passed to the constructor. This should be used when selecting a random
move for player 2 in the selectPlayerTwoMove method.
The Game Class has a constructor that takes one parameter.
a. A reference to a Random Class object that is instantiated in the driver class.
The Game class has a public non-static method called selectPlayerTwoMove. The
method will select a random move from the 1D primitive character array attribute that
stores the respective move (from 2b). This method is intended to select player 2's move
only. This should not be used for player 1. The method should return a primitive
character.
The Game class has a public non-static method called play. play will simulate a round
of the game where player 1 must win against player 2. The method has no parameters.
The method should return a value 1 if the player 1 wins the game, if not return 2 or some
other value.
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

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

What did Rogers mean by unconditional positive regard?

Answered: 1 week ago

Question

LO6 Describe how to choose among the recruitment sources.

Answered: 1 week ago