game.interfaces
Class Cost

java.lang.Object
  |
  +--game.interfaces.Cost
Direct Known Subclasses:
ElementCost

public class Cost
extends java.lang.Object

An interface for costs.


Field Summary
protected  float decay
          Rate at which value in associated Infrastructure class decays.
protected  float food
          Food require required.
protected  boolean persistent
          Whether this cost is persistent.
protected  float production
          Production, sometimes called resources (I prefer production), required.
protected  float recruits
          The cost in recruits.
protected  float services
          Services.
 
Constructor Summary
Cost()
          Constructor.
 
Method Summary
 void add(Cost cost)
          Add the parameter cost to this one.
 float getDecay()
          Return the amount of decay.
 float getFood()
          Return the amount of food.
 Cost getNormalizedCost()
          Normalizes Cost.
 boolean getPersistent()
          Return whether persistent.
 float getProduction()
          Return the amount of production.
 float getRecruits()
          Return the recruits required.
 float getServices()
          Return the amount of services.
 void multiply(float multiplier)
          Multiply all costs by the parameter.
 void setDecay(float value)
          Set the amount of decay.
 void setFood(float value)
          Set the amount of food.
 void setPersistent(boolean value)
          Set whether persistent.
 void setProduction(float value)
          Set the amount of production.
 void setRecruits(float value)
          Set the recruits required.
 void setServices(float value)
          Set the amount of services.
 boolean subtract(Cost toPay)
          Tries to subtract another Cost object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

food

protected float food
Food require required.


production

protected float production
Production, sometimes called resources (I prefer production), required.


services

protected float services
Services.


decay

protected float decay
Rate at which value in associated Infrastructure class decays.


persistent

protected boolean persistent
Whether this cost is persistent.


recruits

protected float recruits
The cost in recruits.

Constructor Detail

Cost

public Cost()
Constructor.

Method Detail

setFood

public void setFood(float value)
Set the amount of food.

Parameters:
value - the amount of food.

getFood

public float getFood()
Return the amount of food.

Returns:
the amount of food.

setProduction

public void setProduction(float value)
Set the amount of production.

Parameters:
value - the amount of production.

getProduction

public float getProduction()
Return the amount of production.

Returns:
the amount of production.

setServices

public void setServices(float value)
Set the amount of services.

Parameters:
value - the amount of services.

getServices

public float getServices()
Return the amount of services.

Returns:
the amount of services.

setDecay

public void setDecay(float value)
Set the amount of decay.

Parameters:
value - the amount of decay.

getDecay

public float getDecay()
Return the amount of decay.

Returns:
the amount of decay.

setPersistent

public void setPersistent(boolean value)
Set whether persistent.

Parameters:
value - true if persistent.

getPersistent

public boolean getPersistent()
Return whether persistent.

Returns:
whetehr persistent.

setRecruits

public void setRecruits(float value)
Set the recruits required.

Parameters:
value - the recruits required.

getRecruits

public float getRecruits()
Return the recruits required.

Returns:
the recruits required.

add

public void add(Cost cost)
Add the parameter cost to this one. Decay and presistent are ignored.


multiply

public void multiply(float multiplier)
Multiply all costs by the parameter. Decay and presistent are ignored.


subtract

public boolean subtract(Cost toPay)
Tries to subtract another Cost object. Will return true if, and only if, all components of other Cost are at least equal to this Cost components. In such a case, this object's components will be loweredaccordingly. If the other Cost is too high, return is false and this Cost remains unchanged.


getNormalizedCost

public Cost getNormalizedCost()
Normalizes Cost. The result is a new Cost with the same proportions of food, production... as this one, but the sum of all these is 1.