Class HumanPlayer

java.lang.Object
  extended by HumanPlayer
All Implemented Interfaces:
Player

public class HumanPlayer
extends java.lang.Object
implements Player

HumanPlayer is a Player controlled by a human user sitting at the console.


Constructor Summary
HumanPlayer()
           
 
Method Summary
 BoardPoint getNextMove()
          This method will prompt the user until she enters a string corresponding to a BoardPoint; after she does that, it will return a BoardPoint for that String.
 boolean isHuman()
           Returns true if this Player is human.
 Ship placeOneShip()
          This method will prompt the user to place a ship, as per the project writeup.
 void setBoard(Grid grid)
           Sets the board for this Player to the given Grid.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HumanPlayer

public HumanPlayer()
Method Detail

placeOneShip

public Ship placeOneShip()
This method will prompt the user to place a ship, as per the project writeup. HumanPlayer should know whether or not the player is trying to place a ship of a valid type, but this ship placement may or may not be legal given the current state of the Grid.

Specified by:
placeOneShip in interface Player
Returns:
a Ship object

getNextMove

public BoardPoint getNextMove()
This method will prompt the user until she enters a string corresponding to a BoardPoint; after she does that, it will return a BoardPoint for that String.

Specified by:
getNextMove in interface Player
Returns:
the BoardPoint of the Player's desired move.

isHuman

public boolean isHuman()
Description copied from interface: Player
Returns true if this Player is human.

Specified by:
isHuman in interface Player
Returns:
true

setBoard

public void setBoard(Grid grid)
Description copied from interface: Player
Sets the board for this Player to the given Grid.

Specified by:
setBoard in interface Player
Parameters:
grid - this Player's board.