Monopoly
Class Card

java.lang.Object
  extended by Monopoly.Card
All Implemented Interfaces:
Interactive
Direct Known Subclasses:
GetOutOfJailCard, GoToJailCard, MoneyCard, MoveBackCard, MoveToCard, NearestCompanyCard, NearestTrainStationCard

public abstract class Card
extends java.lang.Object
implements Interactive

Abstract class Card. Represents a card of the Monopoly game. Invariant: Once created and until destroyed instances of Card subclasses will have an identifing color(int) and a text(String).


Constructor Summary
Card(java.lang.String t, int c)
          Creates a new Card object.
 
Method Summary
abstract  void act(Monopoly game)
          Executes the action described by the card's text.
 int getColor()
          Get the color of the card (Accessor).
 java.lang.String getText()
          Get the text of the card (Accessor).
 java.lang.String toString()
          Get a String identifying the card.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Card

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

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

getText

public java.lang.String getText()
Get the text of the card (Accessor).

Returns:
the text(String) of the card
Precondition:
Always valid
Postcondition:
The same text is always returned

getColor

public int getColor()
Get the color of the card (Accessor).

Returns:
the color(int) of the card
Precondition:
Always valid
Postcondition:
The same color is always returned

toString

public java.lang.String toString()
Get a String identifying the card.

Overrides:
toString in class java.lang.Object
Returns:
the text(String) of the card
Precondition:
Always valid
Postcondition:
The same text is always returned

act

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

Specified by:
act in interface Interactive
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