Class Move

java.lang.Object
  extended by Move
All Implemented Interfaces:
java.io.Serializable

public class Move
extends java.lang.Object
implements java.io.Serializable

A class encapsulating a player move during the game.

See Also:
Serialized Form

Field Summary
static int NONE
          Constant representing no move is made on this turn (loses against anything else).
static int PAPER
          Constant representing the paper.
static int ROCK
          Constant representing the rock.
static int SCISSORS
          Constant representing the scissors.
 
Constructor Summary
Move(int type)
          Constructs a game move.
 
Method Summary
 boolean beats(Move m)
          Returns true if this Move beats the given Move.
 int getType()
          Returns the type of this move.
 java.lang.String toString()
          Returns the type of move it was.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
Constant representing no move is made on this turn (loses against anything else).

See Also:
Constant Field Values

ROCK

public static final int ROCK
Constant representing the rock.

See Also:
Constant Field Values

PAPER

public static final int PAPER
Constant representing the paper.

See Also:
Constant Field Values

SCISSORS

public static final int SCISSORS
Constant representing the scissors.

See Also:
Constant Field Values
Constructor Detail

Move

public Move(int type)
Constructs a game move.

Parameters:
type - the type of move; either NONE, ROCK, PAPER, or SCISSORS.
Method Detail

getType

public int getType()
Returns the type of this move.

Returns:
NONE, ROCK, PAPER, or SCISSORS.

beats

public boolean beats(Move m)
Returns true if this Move beats the given Move. Rock beats scissors, scissors beats paper, paper beats rock, anything beats none. Any other combination is a tie.

Parameters:
m - the move to compare to.

toString

public java.lang.String toString()
Returns the type of move it was.

Overrides:
toString in class java.lang.Object
Returns:
"rock", "paper", or "scissors".