JSettlers v1.0.6 API
Built ${date}

soc.game
Class SOCResourceSet

java.lang.Object
  extended bysoc.game.SOCResourceSet
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class SOCResourceSet
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

This represents a collection of clay, ore, sheep, wheat, and wood resources.

See Also:
Serialized Form

Field Summary
static SOCResourceSet EMPTY_SET
           
 
Constructor Summary
SOCResourceSet()
          Make an empty resource set
SOCResourceSet(int cl, int or, int sh, int wh, int wo, int uk)
          Make a resource set with stuff in it
 
Method Summary
 void add(int amt, int rtype)
          add an amount to a resource
 void add(SOCResourceSet rs)
          add an entire resource set
 void clear()
          set the number of resources to zero
 boolean contains(SOCResourceSet sub)
           
 SOCResourceSet copy()
           
 boolean equals(java.lang.Object anObject)
           
 int getAmount(int rtype)
           
 int getTotal()
           
static boolean gte(SOCResourceSet a, SOCResourceSet b)
           
 int hashCode()
           
static boolean lte(SOCResourceSet a, SOCResourceSet b)
           
 void setAmount(int amt, int rtype)
          set the amount of a resource
 void setAmounts(SOCResourceSet set)
          copy a resource set into this one
 void subtract(int amt, int rtype)
          subtract an amount from a resource
 void subtract(SOCResourceSet rs)
          subtract an entire resource set
 java.lang.String toShortString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_SET

public static final SOCResourceSet EMPTY_SET
Constructor Detail

SOCResourceSet

public SOCResourceSet()
Make an empty resource set


SOCResourceSet

public SOCResourceSet(int cl,
                      int or,
                      int sh,
                      int wh,
                      int wo,
                      int uk)
Make a resource set with stuff in it

Parameters:
cl - number of clay resources
or - number of ore resources
sh - number of sheep resources
wh - number of wheat resources
wo - number of wood resources
uk - number of unknown resources
Method Detail

clear

public void clear()
set the number of resources to zero


getAmount

public int getAmount(int rtype)
Parameters:
rtype - the type of resource
Returns:
the number of a kind of resource

getTotal

public int getTotal()
Returns:
the total number of resources

setAmount

public void setAmount(int amt,
                      int rtype)
set the amount of a resource

Parameters:
rtype - the type of resource
amt - the amount

add

public void add(int amt,
                int rtype)
add an amount to a resource

Parameters:
rtype - the type of resource
amt - the amount

subtract

public void subtract(int amt,
                     int rtype)
subtract an amount from a resource

Parameters:
rtype - the type of resource
amt - the amount

add

public void add(SOCResourceSet rs)
add an entire resource set

Parameters:
rs - the resource set

subtract

public void subtract(SOCResourceSet rs)
subtract an entire resource set

Parameters:
rs - the resource set

gte

public static boolean gte(SOCResourceSet a,
                          SOCResourceSet b)
Parameters:
a - set A
b - set B
Returns:
true if each resource type in set A is >= each resource type in set B

lte

public static boolean lte(SOCResourceSet a,
                          SOCResourceSet b)
Parameters:
a - set A
b - set B
Returns:
true if each resource type in set A is <= each resource type in set B

toString

public java.lang.String toString()
Returns:
a human readable form of the set

toShortString

public java.lang.String toShortString()
Returns:
a human readable form of the set

contains

public boolean contains(SOCResourceSet sub)
Parameters:
sub - the sub set
Returns:
true if sub is in this set

equals

public boolean equals(java.lang.Object anObject)
Parameters:
anObject - the object in question
Returns:
true if the argument contains the same data

hashCode

public int hashCode()
Returns:
a hashcode for this data

copy

public SOCResourceSet copy()
Returns:
a copy of this resource set

setAmounts

public void setAmounts(SOCResourceSet set)
copy a resource set into this one

Parameters:
set - the set to copy

JSettlers v1.0.6 API
Built ${date}