SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AGAdult Class Reference

An adult person who can have a job. More...

#include <AGAdult.h>

Inheritance diagram for AGAdult:
AGPerson

Public Member Functions

 AGAdult (int age)
 Initialises the base class and the own attributes. More...
 
virtual bool decide (SUMOReal probability) const
 Lets the person make a decision. More...
 
virtual int getAge () const
 Provides the age of the person. More...
 
const AGWorkPositiongetWorkPosition () const
 Provides the work position of the adult. More...
 
bool isWorking () const
 States whether this person occupies a work position at present. More...
 
void lostWorkPosition ()
 Called when the adult has lost her job. More...
 
void print () const
 Puts out a summary of the attributes. More...
 
void resignFromWorkPosition ()
 Called when the adult should resign her job. More...
 
void tryToWork (SUMOReal employmentRate, std::vector< AGWorkPosition > *wps)
 Tries to get a new work position. More...
 

Protected Attributes

int age
 

Static Private Member Functions

static AGWorkPositionrandomFreeWorkPosition (std::vector< AGWorkPosition > *wps)
 Randomly selects a free work position from the list. More...
 

Private Attributes

AGWorkPositionwork
 

Detailed Description

An adult person who can have a job.

AGAdult extends AGPerson by various methods to handle work life.

Definition at line 58 of file AGAdult.h.

Constructor & Destructor Documentation

AGAdult::AGAdult ( int  age)

Initialises the base class and the own attributes.

Parameters
[in]theage of the AGPerson

Definition at line 59 of file AGAdult.cpp.

Member Function Documentation

bool AGPerson::decide ( SUMOReal  probability) const
virtualinherited

Lets the person make a decision.

The higher the degree of belief is, the more likely this method returns true.

Parameters
[in]degreeOfBeliefhow strong the person beliefs the proposition
Returns
whether the person agrees with the proposition

Definition at line 63 of file AGPerson.cpp.

References RandHelper::rand().

Referenced by tryToWork().

int AGPerson::getAge ( ) const
virtualinherited

Provides the age of the person.

Returns
the age in years

Definition at line 57 of file AGPerson.cpp.

References AGPerson::age.

const AGWorkPosition & AGAdult::getWorkPosition ( ) const

Provides the work position of the adult.

You should test before, whether the adult has a job. If you call this method and the adult has no job, then a runtime exception is thrown.

Returns
the work position
Exceptions
runtime_errorthe adult has no work position

Definition at line 117 of file AGAdult.cpp.

References work.

bool AGAdult::isWorking ( ) const

States whether this person occupies a work position at present.

Returns
true if she has a work position

Definition at line 94 of file AGAdult.cpp.

References work.

void AGAdult::lostWorkPosition ( )

Called when the adult has lost her job.

This method is called from AGWorkPosition, whenever the adult lost her job, be it because it got fired or because its resignation has been accepted.

Definition at line 101 of file AGAdult.cpp.

References work.

Referenced by AGWorkPosition::let().

void AGAdult::print ( ) const
virtual

Puts out a summary of the attributes.

Reimplemented from AGPerson.

Definition at line 65 of file AGAdult.cpp.

References AGPerson::age, and work.

AGWorkPosition * AGAdult::randomFreeWorkPosition ( std::vector< AGWorkPosition > *  wps)
staticprivate

Randomly selects a free work position from the list.

Parameters
[in]thelist of work positions (free or not)
Returns
the chosen free work position

Definition at line 46 of file AGAdult.cpp.

References RandHelper::rand().

Referenced by tryToWork().

void AGAdult::resignFromWorkPosition ( )

Called when the adult should resign her job.

This method asks the WorkPosition to quit the job. The WorkPosition in turn calls AGAdult::lostWorkPosition.

Definition at line 108 of file AGAdult.cpp.

References AGWorkPosition::let(), and work.

void AGAdult::tryToWork ( SUMOReal  employmentRate,
std::vector< AGWorkPosition > *  wps 
)

Tries to get a new work position.

Depending on the employment rate, this adult randomly gets unemployed or employed. If it gets employed, it randomly chooses one of the free work positions and occupies it.

The new state (employed or unemployed) is chosen independently from the previous state. If the adult was employed, her previous job is given up.

Parameters
[in]employmentRate (1 - unemploymentRate)
[in]wps the list of work positions (open or not) in the city

Definition at line 72 of file AGAdult.cpp.

References AGPerson::decide(), AGWorkPosition::let(), randomFreeWorkPosition(), AGWorkPosition::take(), and work.

Field Documentation

int AGPerson::age
protectedinherited
AGWorkPosition* AGAdult::work
private

The work position of this adult.

A pointer to the work position or 0 if the adult is unemployed at present.

Definition at line 120 of file AGAdult.h.

Referenced by getWorkPosition(), isWorking(), lostWorkPosition(), print(), resignFromWorkPosition(), and tryToWork().


The documentation for this class was generated from the following files: