Household
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
cpc.sau.agents
Class Household
java.lang.Objectcpc.sau.agents.Household
public class Household
- extends java.lang.Object
An object representing a household. This class is designed to simulate a household that is comprised of a number of persons(Individual objects) and that owns land(Parcel objects).It includes several attributes and methods which allow the user to manipulate the household roster and the land owned by the household.
individuals : a roster(arraylist) of all Individual objects belonging to
the Household
wealth : the total wealth of the household
parcels : an arraylist of parcels belonging to the household.
landOwned : a hashtable that stores information about whether a household
owns each of the parcels in the parcels arraylist. It uses the parcel ID, a string, as
the key to store the corresponding boolean value. If a key's corresponding boolean
value is true, the household owns the parcel.
areaLandOwned : total area of the parcels owned by the household
hhSize: number of individuals in the household
householdID: unique ID for the household
When creating a household, the householdID is automatically initialized beginning at 1 and increasing incrementally by 1 for each new Household created. The ID can be changed with its set method.
| Field Summary | |
|---|---|
static int |
houseId
|
| Constructor Summary | |
|---|---|
Household()
Constructs a new household object. |
|
| Method Summary | |
|---|---|
void |
addParcel(Parcel pal,
boolean bln)
Adds a new parcel to this household and indicates whether this parcel is owned by this household. |
void |
deleteParcel(Parcel pal)
Deletes a parcel from the household parcel list. |
double |
getAreaLandOwned()
Calculates and returns the total area of all parcels belonging to this household |
int |
getHHSize()
Returns the number of individuals in the household |
int |
getHouseholdId()
Returns the household ID |
java.util.ArrayList |
getindivs()
Returns the individual arraylist of this household |
boolean |
getLandOwned(Parcel pal)
Returns a boolean value indicating whether this parcel is owned by this household. |
java.util.ArrayList |
getParcels()
Returns the parcel list of this household |
double |
getWealth()
Returns the wealth of this household |
void |
indivBirth(Individual indiNew)
Adds a new individual agent to household. |
void |
indivDie(Individual indiDie)
Removes an individual agent from this household agent |
void |
setHouseholdId(int hid)
Sets the household ID to a user-defined value. |
void |
setIndivs(java.util.ArrayList<Individual> indi)
Defines the household individuals arraylist |
void |
setWealth(double wealth)
Sets the wealth of this household |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
houseId
public static int houseId
| Constructor Detail |
|---|
Household
public Household()
- Constructs a new household object. The individuals list, parcels list
and other variables are empty. They should be initialized using their set methods.
Only the householdID is initialized automatically by the constructor, but it
can be changed with its set method.
| Method Detail |
|---|
setIndivs
public void setIndivs(java.util.ArrayList<Individual> indi)
- Defines the household individuals arraylist
- Parameters:
indi- an arraylist containing all individual agents.
getindivs
public java.util.ArrayList getindivs()
- Returns the individual arraylist of this household
- Returns:
- an arraylist containing all individual agents in this household agent
setWealth
public void setWealth(double wealth)
- Sets the wealth of this household
- Parameters:
wealth- wealth of this household
getWealth
public double getWealth()
- Returns the wealth of this household
- Returns:
- the wealth of this household
getHHSize
public int getHHSize()
- Returns the number of individuals in the household
- Returns:
- the number of individuals in this household
setHouseholdId
public void setHouseholdId(int hid)
- Sets the household ID to a user-defined value.
- Parameters:
hid- an integer the user defines as the household ID. Every household is initialized with a new ID when created, but it can be changed with this method.
getHouseholdId
public int getHouseholdId()
- Returns the household ID
- Returns:
- the ID of this household agent
indivBirth
public void indivBirth(Individual indiNew)
- Adds a new individual agent to household.
- Parameters:
indiNew- the new individual agent
indivDie
public void indivDie(Individual indiDie)
- Removes an individual agent from this household agent
addParcel
public void addParcel(Parcel pal, boolean bln)
- Adds a new parcel to this household and indicates whether
this parcel is owned by this household.
- Parameters:
pal- the parcel object that will be added to this householdbln- the boolean value indicating whether this household owns the parcel
getLandOwned
public boolean getLandOwned(Parcel pal)
- Returns a boolean value indicating whether this parcel is owned
by this household.
It uses the parcel ID(pid) as the key and stores corresponding boolean value
in a hashtable.
When given a parcel ID, it searches the hashtable by the key.
If the parcel ID is found, it returns its corresponding boolean value.
If the parcel ID is not found in in the hashtable, it returns null.
- Parameters:
pal- the parcel to be checked- Returns:
- a boolean value indicating whether this household own this parcel
deleteParcel
public void deleteParcel(Parcel pal)
- Deletes a parcel from the household parcel list.
It updates the landOwned hashtable at the same time by
deleting the key and the corresponding boolean value in the hashtable
- Parameters:
pal- the parcel to be deleted
getParcels
public java.util.ArrayList getParcels()
- Returns the parcel list of this household
- Returns:
- an arraylist including all parcels in the household
getAreaLandOwned
public double getAreaLandOwned()
- Calculates and returns the total area of all parcels belonging to this household
- Returns:
- the total area of parcels in this household
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

cpc.sau.agents.Household

