Monopoly
Class MoneyCard

java.lang.Object
  extended by Monopoly.Card
      extended by Monopoly.MoneyCard
All Implemented Interfaces:
Interactive
Direct Known Subclasses:
GetFromEveryPlayer, GetMoneyCard, PayForEveryBuilding, PayMoneyCard, PayToEveryPlayer

public abstract class MoneyCard
extends Card

This is the abstract class MoneyCard. Invariant: Once created and until destroyed an instance of a subclass will represent a MoneyCard of the Monopoly game. It always has an amount of money (greater than zero). When drawn the player either pays or collects that amount of money.


Constructor Summary
MoneyCard(int value, java.lang.String t, int c)
          Creates a new MoneyCard object.
 
Method Summary
abstract  void act(Monopoly game)
          Executes the action described by the card's text.
 int getValue()
          Returns the amount of money to be payed or received.
 
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

MoneyCard

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

Parameters:
value - the amount to pay or receive
t - the message that appears on the card
c - the color of the card
Method Detail

getValue

public int getValue()
Returns the amount of money to be payed or received.

Returns:
value
Precondition:
Always valid
Postcondition:
The same value 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
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