org.cfpm.caves.za
Class Household

java.lang.Object
  extended by org.cfpm.caves.za.Household
All Implemented Interfaces:
uchicago.src.sim.gui.Drawable

public class Household
extends java.lang.Object
implements uchicago.src.sim.gui.Drawable

This class represents a household in a village. A household consists of a group of agents, usually but not necessarily related, who pool and share all resources. Decisions on the household level are taken by a designated household head. Used as a shadow fact in Jess.

Author:
Shah Alam, Ruth Meyer, Scott Moss

Field Summary
(package private)  double cash
          the household's available money
(package private)  jess.Value church
          the church this household belongs to
(package private)  double expectedIncome
          the household's expected monthly income
(package private)  Person head
          the household head
(package private)  jess.Value id
          the household ID
(package private)  jess.Value[] memberIDs
          the names of the household members (for easier access in Jess)
(package private)  java.util.ArrayList<Person> members
          the household members
(package private)  SouthAfricaModel model
          reference to the model
(package private)  double monthlyFoodCost
          the household's monthly food cost
(package private)  NetworkNode node
          the associated network node for the kinship network
private  java.beans.PropertyChangeSupport pcs
           
(package private)  double spendingCommitments
          the household's commitments to pay for stuff
(package private)  jess.Value village
          the village this household is situated in
(package private)  int x
          the x coordinate of the household's position on the 2D grid
(package private)  int y
          the y coordinate of the household's position on the 2D grid
 
Constructor Summary
Household(SouthAfricaModel model)
          Creates a new empty household.
Household(SouthAfricaModel model, java.lang.String id, jess.Value church, Village village)
          Create a new household for a newly-wed couple during the simulation
 
Method Summary
private  void accommodate(java.util.ArrayList<Person> orphans)
          internal function: let the given orphans join the household
 void addCash(double cash)
          adds the given cash to the household's cash
 void addMember(Person member)
          Adds the given person as a household member
 void addPropertyChangeListener(java.beans.PropertyChangeListener p)
          adds a property change listener (for Jess)
 double calculateExpectedIncome(double wages)
          calculates the expected income, taking state grants and wages from employment into account
 double calculateMonthlyFoodCost()
          calculates the monthly food cost depending on the members' age and gender, applying the food cost constants defined in the model
 double contributeToBurial(java.lang.String deceasedPerson, java.lang.String deceasedHousehold, boolean isKin)
          contribute money to the burial costs of a related or neighbouring household
private  void determineNewHead(Person oldHead)
          internal function: finds a new household head among the members
private  void dissolve(Person heir)
          internal function: this household dissolves and the given heir inherits all assets
 void draw(uchicago.src.sim.gui.SimGraphics g)
          draws a black circle for this household on the 2D grid display
private  Person findEldestMember()
          internal function: finds the eldest person amongst the members to take over as household head
private  Person findNextEldestMember(Person p)
          internal function: finds the member who is eldest after the given member
 double getCash()
          returns the household's cash
 jess.Value getChurch()
          returns the church this household belongs to
 double getExpectedIncome()
          returns the expected monthly income
 Person getHead()
          returns the household's head
 jess.Value getHeadID()
          returns the name of the household head.
 jess.Value getId()
          returns the household ID
 jess.Value[] getMemberIDs()
          returns the member IDs
 java.util.ArrayList<Person> getMembers()
          returns the household's members
 SouthAfricaModel getModel()
          returns a reference to the model
 double getMonthlyFoodCost()
          returns the monthly food cost
 NetworkNode getNode()
          returns the associated network node
 double getSpendingCommitments()
          returns the spending commitments of this household (sum of payments this household has agreed to make, e.g. food costs or wages for piece jobs)
 jess.Value getVillage()
          returns the village this household belongs to
 int getX()
          returns the x coordinate of the household's location
 int getY()
          returns the y coordinate of the household's location
(package private)  boolean hasMember(Person p)
          checks if the given person is a member of the household
(package private)  boolean isKinOf(Household hh)
          checks if the given household is related to this household, i.e. if there is a kinhip link between the two households.
(package private)  int numberOfAdults()
          return the number of adults amongst the members
(package private)  int numberOfChildren()
          return the number of children amongst the members
(package private)  int numberOfSeniors()
          return the number of seniors amongst the members
(package private)  Person pickRandomAdult()
          returns a random adult from the household members
 void removeCash(double cash)
          removes the specified amount from the household's cash
 void removeMember(Person member)
          Removes the given person from the household.
 void removePropertyChangeListener(java.beans.PropertyChangeListener p)
          removes a property change listener (for Jess)
 void setCash(double cash)
          sets the household's cash to the given amount
 void setChurch(java.lang.String ch)
          sets the church this household belongs to
 void setChurch(jess.Value ch)
          sets the church this household belongs to
 void setExpectedIncome(double expectedIncome)
          sets the expected monthly income
 void setHead(Person head)
          sets the household's head
 void setId(java.lang.String newId)
          sets the household ID
 void setId(jess.Value newId)
          sets the household ID
 void setMemberIDs(jess.Value[] IDs)
          sets the member IDs
 void setMembers(java.util.ArrayList<Person> mems)
          sets the household's members
 void setMonthlyFoodCost(double monthlyFoodCost)
          sets the monthly food cost
 void setNode(NetworkNode node)
          sets the associated network node
 void setSpendingCommitments(double spendingCommitments)
          sets the spending commitments of this household
 void setVillage(java.lang.String villageString)
          sets the village this household belongs to
 void setVillage(jess.Value village)
          sets the village this household belongs to
 void setX(int x)
          sets the x coordinate of the household's location
 void setXY(int x, int y)
          sets the household's location on the 2D grid
 void setY(int y)
          sets the y coordinate of the household's location
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

id

jess.Value id
the household ID


church

jess.Value church
the church this household belongs to


village

jess.Value village
the village this household is situated in


head

Person head
the household head


members

java.util.ArrayList<Person> members
the household members


memberIDs

jess.Value[] memberIDs
the names of the household members (for easier access in Jess)


cash

double cash
the household's available money


monthlyFoodCost

double monthlyFoodCost
the household's monthly food cost


expectedIncome

double expectedIncome
the household's expected monthly income


spendingCommitments

double spendingCommitments
the household's commitments to pay for stuff


node

NetworkNode node
the associated network node for the kinship network


x

int x
the x coordinate of the household's position on the 2D grid


y

int y
the y coordinate of the household's position on the 2D grid


model

SouthAfricaModel model
reference to the model


pcs

private java.beans.PropertyChangeSupport pcs
Constructor Detail

Household

public Household(SouthAfricaModel model)
Creates a new empty household. Used during model initialisation

Parameters:
model - the model

Household

public Household(SouthAfricaModel model,
                 java.lang.String id,
                 jess.Value church,
                 Village village)
Create a new household for a newly-wed couple during the simulation

Parameters:
model - the model
id - the household ID
church - the church the household belongs to
village - the village the household is situated
Method Detail

setId

public void setId(jess.Value newId)
sets the household ID

Parameters:
newId - the household ID

setId

public void setId(java.lang.String newId)
sets the household ID

Parameters:
newId - the household ID as String

getId

public jess.Value getId()
returns the household ID

Returns:
household ID

getHead

public Person getHead()
returns the household's head

Returns:
hh head

setHead

public void setHead(Person head)
sets the household's head

Parameters:
head - the hh head

getHeadID

public jess.Value getHeadID()
returns the name of the household head. Provided for easier access from Jess.

Returns:
name of the household head

setMembers

public void setMembers(java.util.ArrayList<Person> mems)
sets the household's members

Parameters:
mems - list of members

getMembers

public java.util.ArrayList<Person> getMembers()
returns the household's members

Returns:
list of members

addMember

public void addMember(Person member)
Adds the given person as a household member

Parameters:
member - the new member

removeMember

public void removeMember(Person member)
Removes the given person from the household. If this person was the last adult member, the household will dissolve unless any children left can't be accommodated by relatives.

Parameters:
member - the leaving member

accommodate

private void accommodate(java.util.ArrayList<Person> orphans)
internal function: let the given orphans join the household

Parameters:
orphans - list of orphaned children

dissolve

private void dissolve(Person heir)
internal function: this household dissolves and the given heir inherits all assets

Parameters:
heir - the heir

determineNewHead

private void determineNewHead(Person oldHead)
internal function: finds a new household head among the members

Parameters:
oldHead - the old head who has died

findEldestMember

private Person findEldestMember()
internal function: finds the eldest person amongst the members to take over as household head

Returns:
eldest member

findNextEldestMember

private Person findNextEldestMember(Person p)
internal function: finds the member who is eldest after the given member

Parameters:
p - member
Returns:
next eldest member

getMemberIDs

public jess.Value[] getMemberIDs()
returns the member IDs

Returns:
list of member names

setMemberIDs

public void setMemberIDs(jess.Value[] IDs)
sets the member IDs

Parameters:
IDs - list of member names

setChurch

public void setChurch(jess.Value ch)
sets the church this household belongs to

Parameters:
ch - the church

setChurch

public void setChurch(java.lang.String ch)
sets the church this household belongs to

Parameters:
ch - the church as String

getChurch

public jess.Value getChurch()
returns the church this household belongs to

Returns:
the church

getNode

public NetworkNode getNode()
returns the associated network node

Returns:
the node

setNode

public void setNode(NetworkNode node)
sets the associated network node

Parameters:
node - the node

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener p)
adds a property change listener (for Jess)


removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener p)
removes a property change listener (for Jess)


getCash

public double getCash()
returns the household's cash

Returns:
amount of cash

setCash

public void setCash(double cash)
sets the household's cash to the given amount

Parameters:
cash - amount of cash

addCash

public void addCash(double cash)
adds the given cash to the household's cash

Parameters:
cash - amount to add

removeCash

public void removeCash(double cash)
removes the specified amount from the household's cash

Parameters:
cash - amount to remove

getExpectedIncome

public double getExpectedIncome()
returns the expected monthly income

Returns:
expected monthly income

setExpectedIncome

public void setExpectedIncome(double expectedIncome)
sets the expected monthly income

Parameters:
expectedIncome - the expected monthly income

getMonthlyFoodCost

public double getMonthlyFoodCost()
returns the monthly food cost

Returns:
monthly food cost

setMonthlyFoodCost

public void setMonthlyFoodCost(double monthlyFoodCost)
sets the monthly food cost

Parameters:
monthlyFoodCost - monthly food cost

calculateMonthlyFoodCost

public double calculateMonthlyFoodCost()
calculates the monthly food cost depending on the members' age and gender, applying the food cost constants defined in the model

Returns:
monthly food cost

calculateExpectedIncome

public double calculateExpectedIncome(double wages)
calculates the expected income, taking state grants and wages from employment into account

Parameters:
wages - wages from employment
Returns:
expected income

contributeToBurial

public double contributeToBurial(java.lang.String deceasedPerson,
                                 java.lang.String deceasedHousehold,
                                 boolean isKin)
contribute money to the burial costs of a related or neighbouring household

Parameters:
deceasedPerson - the deceased
deceasedHousehold - the deceased's household
isKin - kinhsip status (true = related, false = not related)
Returns:
amount of contribution

numberOfAdults

int numberOfAdults()
return the number of adults amongst the members

Returns:
number of adults (ages 18-59)

numberOfChildren

int numberOfChildren()
return the number of children amongst the members

Returns:
number of children (ages 0-17)

numberOfSeniors

int numberOfSeniors()
return the number of seniors amongst the members

Returns:
number of seniors (ages >= 60)

setVillage

public void setVillage(jess.Value village)
sets the village this household belongs to

Parameters:
village - the village

setVillage

public void setVillage(java.lang.String villageString)
sets the village this household belongs to

Parameters:
villageString - the village as a String

getVillage

public jess.Value getVillage()
returns the village this household belongs to

Returns:
the village

pickRandomAdult

Person pickRandomAdult()
returns a random adult from the household members

Returns:
random adult member

hasMember

boolean hasMember(Person p)
checks if the given person is a member of the household

Parameters:
p - the person in question
Returns:
true if p is a member, false otherwise

getSpendingCommitments

public double getSpendingCommitments()
returns the spending commitments of this household (sum of payments this household has agreed to make, e.g. food costs or wages for piece jobs)

Returns:
the spending commitments

setSpendingCommitments

public void setSpendingCommitments(double spendingCommitments)
sets the spending commitments of this household

Parameters:
spendingCommitments - the spending commitments

isKinOf

boolean isKinOf(Household hh)
checks if the given household is related to this household, i.e. if there is a kinhip link between the two households.

Parameters:
hh - the household in question
Returns:
true if the households are related, false otherwise

getModel

public SouthAfricaModel getModel()
returns a reference to the model

Returns:
the model

getX

public int getX()
returns the x coordinate of the household's location

Specified by:
getX in interface uchicago.src.sim.gui.Drawable
Returns:
x coordinate

getY

public int getY()
returns the y coordinate of the household's location

Specified by:
getY in interface uchicago.src.sim.gui.Drawable
Returns:
y coordinate

draw

public void draw(uchicago.src.sim.gui.SimGraphics g)
draws a black circle for this household on the 2D grid display

Specified by:
draw in interface uchicago.src.sim.gui.Drawable

setX

public void setX(int x)
sets the x coordinate of the household's location

Parameters:
x - the x coordinate

setY

public void setY(int y)
sets the y coordinate of the household's location

Parameters:
y - the y coordinate

setXY

public void setXY(int x,
                  int y)
sets the household's location on the 2D grid

Parameters:
x - the x coordinate
y - the y coordinate