SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AGPerson.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Parent object of every person, contains age and any natural characteristic
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 // activitygen module
14 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 
25 
26 // ===========================================================================
27 // included modules
28 // ===========================================================================
29 #ifdef _MSC_VER
30 #include <windows_config.h>
31 #else
32 #include <config.h>
33 #endif
34 
35 #include "AGPerson.h"
37 #include <iostream>
38 
39 
40 // ===========================================================================
41 // method definitions
42 // ===========================================================================
43 AGPerson::AGPerson(int age) : age(age) {}
44 
45 
47 
48 
49 void
50 AGPerson::print() const {
51  std::cout << "- Person: Age=" << age << std::endl;
52 }
53 
54 
55 int
57  return age;
58 }
59 
60 
61 bool
62 AGPerson::decide(SUMOReal proba) const {
63  return (RandHelper::rand(1000) < static_cast<int>(1000.0f * proba));
64 }
65 
66 /****************************************************************************/
virtual ~AGPerson()
Cleans up everything.
Definition: AGPerson.cpp:46
static SUMOReal rand()
Returns a random real number in [0, 1)
Definition: RandHelper.h:61
virtual bool decide(SUMOReal probability) const
Lets the person make a decision.
Definition: AGPerson.cpp:62
AGPerson(int age)
Initialises the class attributes.
Definition: AGPerson.cpp:43
int age
Definition: AGPerson.h:72
#define SUMOReal
Definition: config.h:215
virtual int getAge() const
Provides the age of the person.
Definition: AGPerson.cpp:56
virtual void print() const
Puts out a summary of the class properties.
Definition: AGPerson.cpp:50