Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
AGAdult Class Reference

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

#include <AGAdult.h>

Inheritance diagram for AGAdult:
[legend]
Collaboration diagram for AGAdult:
[legend]

Public Member Functions

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

Protected Attributes

int age
 

Static Private Member Functions

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

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 48 of file AGAdult.h.

Constructor & Destructor Documentation

◆ AGAdult()

AGAdult::AGAdult ( int  age)

Initialises the base class and the own attributes.

Parameters
[in]theage of the AGPerson

Definition at line 52 of file AGAdult.cpp.

Member Function Documentation

◆ decide()

bool AGPerson::decide ( double  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 54 of file AGPerson.cpp.

References RandHelper::rand().

Referenced by tryToWork().

Here is the caller graph for this function:

◆ getAge()

int AGPerson::getAge ( ) const
virtualinherited

Provides the age of the person.

Returns
the age in years

Definition at line 48 of file AGPerson.cpp.

References AGPerson::age.

◆ getWorkPosition()

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 ProcessError is thrown.

Returns
the work position
Exceptions
ProcessErrorthe adult has no work position

Definition at line 106 of file AGAdult.cpp.

References work.

◆ isWorking()

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 86 of file AGAdult.cpp.

References work.

◆ lostWorkPosition()

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 92 of file AGAdult.cpp.

References work.

Referenced by AGWorkPosition::let().

Here is the caller graph for this function:

◆ print()

void AGAdult::print ( ) const
virtual

Puts out a summary of the attributes.

Reimplemented from AGPerson.

Definition at line 57 of file AGAdult.cpp.

References AGPerson::age, and work.

◆ randomFreeWorkPosition()

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 38 of file AGAdult.cpp.

References RandHelper::getRandomFrom().

Referenced by tryToWork().

Here is the caller graph for this function:

◆ resignFromWorkPosition()

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 98 of file AGAdult.cpp.

References AGWorkPosition::let(), and work.

◆ tryToWork()

void AGAdult::tryToWork ( double  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)

Parameters
[in]

wps the list of work positions (open or not) in the city

Definition at line 63 of file AGAdult.cpp.

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

Field Documentation

◆ age

int AGPerson::age
protectedinherited

◆ work

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 110 of file AGAdult.h.

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


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