Question: coding for this For this task you have a Game class, rather than your usual Runner. The game creates two Player objects, and has them

coding for this
For this task you have a Game class, rather than your usual Runner. The game creates two Player objects, and has them take turns placing tiles until one player runs out of space. One of the Player objects is a HumanPlayer that is controlled by the user, and the other is a RandomPlayer that places tiles randomly.
Your task is to implement the HumanPlayer and RandomPlayer classes (and their parent Player) according to the specification below, so that the game can run successfully.
Specification
The Player abstract class or interface (your choice) must define the following contract:
A getDirection method, which accepts no parameters, and returns the Direction (either HORIZONTAL or VERTICAL) in which this player will place their tiles.
A canPlay method, which accepts an instance of Board as input. This method should return true if the player can place a tile on the given board, or false if they cannot.
A getNextTile method, which accepts an instance of Board as input, and returns a Tile. If the player is not able to place a tile on the given board, this should return null. If the player can place a tile, then this method should return a valid tile. The state of the given board should be updated (to include the newly played tile) as a side-effect of calling this method.
If you implement Player as an abstract class, then you are free to decide which methods are abstract and which are concrete.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!