Class Player

java.lang.Object
  extended by Player

public class Player
extends java.lang.Object

Represents a player in the game

Version:
1.0

Constructor Summary
Player(java.lang.String name)
          Constructor for objects of class Player
 
Method Summary
 Room getCurrentRoom()
          Returns the room in which the player is currently located
 java.lang.String getName()
          Returns the name of this player
 void goRoom(Command command)
          Try to go to one direction.
 java.lang.String printHelp()
          Print out some help information.
 boolean processCommand(Command command)
          Given a command, process (that is: execute) the command.
 void setCurrentRoom(Room currentRoom)
          Sets the room in which the player is to be located
 void setName(java.lang.String name)
          Set a new name for this player
 boolean takeTurn()
          Take the player's turn in the game
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Player

public Player(java.lang.String name)
Constructor for objects of class Player

Method Detail

getCurrentRoom

public Room getCurrentRoom()
Returns the room in which the player is currently located

Returns:
the room in which the player is currently located

getName

public java.lang.String getName()
Returns the name of this player

Returns:
the player's name

goRoom

public void goRoom(Command command)
Try to go to one direction. If there is an exit, enter the new room, otherwise print an error message.


printHelp

public java.lang.String printHelp()
Print out some help information. Here we print some stupid, cryptic message and a list of the command words.


processCommand

public boolean processCommand(Command command)
Given a command, process (that is: execute) the command.

Parameters:
command - the command to be processed.
Returns:
"true" if the command ends the game, no response otherwise.

setCurrentRoom

public void setCurrentRoom(Room currentRoom)
Sets the room in which the player is to be located

Parameters:
currentRoom - the room in which the player is to be located

setName

public void setName(java.lang.String name)
Set a new name for this player

Parameters:
name - the new name for the player

takeTurn

public boolean takeTurn()
Take the player's turn in the game

Returns:
true if quit flag is to be set in the game