Monopoly
Class GetOutOfJailCard

java.lang.Object
  extended by Monopoly.Card
      extended by Monopoly.GetOutOfJailCard
All Implemented Interfaces:
Collectable, Interactive

public class GetOutOfJailCard
extends Card
implements Collectable

This is the class GetOutOfJailCard. Invariant: Once created and until destroyed an instance of this class will represent a GetOutOfJailCard of the Monopoly game. When drawn it can be kept and used or sold later.


Constructor Summary
GetOutOfJailCard(java.lang.String t, int c)
          Creates a new GetOutOfJailCard object.
 
Method Summary
 void act(Monopoly game)
          Executes the action described by the card's text.
 Player getOwner()
          Get the owner of this card (Accessor).
 void setOwner(Player owner)
          Set the owner of this card (Transformer).
 void use(Monopoly game)
          Releases the owner of this card from prison.
 
Methods inherited from class Monopoly.Card
getColor, getText, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GetOutOfJailCard

public GetOutOfJailCard(java.lang.String t,
                        int c)
Creates a new GetOutOfJailCard object.

Parameters:
t - the message that appears on the card
c - the color of the card
Method Detail

getOwner

public Player getOwner()
Get the owner of this card (Accessor).

Specified by:
getOwner in interface Collectable
Returns:
a Player object who owns this card; null if there is no owner.

setOwner

public void setOwner(Player owner)
Set the owner of this card (Transformer).

Specified by:
setOwner in interface Collectable
Parameters:
owner - the Player object to be set as owner of this card
Precondition:
This card has been picked from owner
Postcondition:
The card belongs to owner and has been added to his properties

act

public void act(Monopoly game)
Executes the action described by the card's text.

Specified by:
act in interface Interactive
Specified by:
act in class Card
Parameters:
game - the Monopoly object where the action will take place
Precondition:
This card has been picked from a Player
Postcondition:
The action described has been executed

use

public void use(Monopoly game)
Releases the owner of this card from prison.

Parameters:
game - the Monopoly object where the action will take place