Class ConsolePlayer
java.lang.Object
castle.comp3021.assignment.protocol.Player
castle.comp3021.assignment.player.ConsolePlayer
- All Implemented Interfaces:
java.lang.Cloneable
public class ConsolePlayer extends Player
The player that makes move according to user input from console.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ConsolePlayer(java.lang.String name)
ConsolePlayer(java.lang.String name, Color color)
-
Method Summary
-
Constructor Details
-
ConsolePlayer
-
ConsolePlayer
public ConsolePlayer(java.lang.String name)
-
-
Method Details
-
nextMove
Choose a move from available moves. This method will be called byGame
object to get the move that the player wants to make when it is the player's turn.ConsolePlayer
returns a move according to user's input in the console. The console input format should conform the format described in the assignment description. (e.g. a1->b3 means move thePiece
atPlace
(x=0,y=0) toPlace
(x=1,y=2)) Note that in theGame
.board, the index starts from 0 in both x and y dimension, while in the console display, x dimension index starts from 'a' and y dimension index starts from 1.Hint: be sure to handle invalid input to avoid invalid
Move
s.Attention: Student should make sure the
Move
returned is valid.Attention:
Place
object uses integer as index of x and y-axis, both starting from 0 to facilitate programming. This is VERY different from the coordinate used in console display.
-