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