Eclipse SUMO - Simulation of Urban MObility
AGPerson.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2010-2024 German Aerospace Center (DLR) and others.
4 // activitygen module
5 // Copyright 2010 TUM (Technische Universitaet Muenchen, http://www.tum.de/)
6 // This program and the accompanying materials are made available under the
7 // terms of the Eclipse Public License 2.0 which is available at
8 // https://www.eclipse.org/legal/epl-2.0/
9 // This Source Code may also be made available under the following Secondary
10 // Licenses when the conditions for such availability set forth in the Eclipse
11 // Public License 2.0 are satisfied: GNU General Public License, version 2
12 // or later which is available at
13 // https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
14 // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
15 /****************************************************************************/
23 // Parent object of every person, contains age and any natural characteristic
24 /****************************************************************************/
25 #include <config.h>
26 
27 #include "AGPerson.h"
29 #include <iostream>
30 
31 
32 // ===========================================================================
33 // method definitions
34 // ===========================================================================
35 AGPerson::AGPerson(int age) : age(age) {}
36 
37 
39 
40 
41 void
42 AGPerson::print() const {
43  std::cout << "- Person: Age=" << age << std::endl;
44 }
45 
46 
47 int
49  return age;
50 }
51 
52 
53 bool
54 AGPerson::decide(double proba) const {
55  return (RandHelper::rand(1000) < static_cast<int>(1000.0f * proba));
56 }
57 
58 
59 /****************************************************************************/
virtual int getAge() const
Provides the age of the person.
Definition: AGPerson.cpp:48
virtual bool decide(double probability) const
Lets the person make a decision.
Definition: AGPerson.cpp:54
virtual ~AGPerson()
Cleans up everything.
Definition: AGPerson.cpp:38
AGPerson(int age)
Initialises the class attributes.
Definition: AGPerson.cpp:35
virtual void print() const
Puts out a summary of the class properties.
Definition: AGPerson.cpp:42
int age
Definition: AGPerson.h:62
static double rand(SumoRNG *rng=nullptr)
Returns a random real number in [0, 1)
Definition: RandHelper.cpp:94