forked from cchsc/ElevatorSimulation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerson.cpp
More file actions
47 lines (38 loc) · 1014 Bytes
/
Person.cpp
File metadata and controls
47 lines (38 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
*TODO LIST
*
* 1.) A direction function to tell which direction the person wants to go.
*
*/
#include "Person.h"
Person::Person(int source, int destination,
int id, int const WEIGHT)
: source_(source), destination_(destination), id_(id),
WEIGHT_(WEIGHT)
{
}
Person::~Person()
{
}
Person & Person::operator=(Person const & p)
{
std::cout << "Operator= overloading.\n";
id() = p.id();
}
std::ostream & operator<<(std::ostream & cout,
Person const & p)
{
cout << "\t<Person Source: " << p.source()
<< "\n\tDestination: " << p.destination()
<< "\n\tID: " << p.id()
<< "\n\tWEIGHT: " << p.WEIGHT()
<< "\n\tDirection: " << p.dir() << ">\n";
return cout;
}
//returns 1, 0, -1 for the direction the person wants to move to
//0 means the person is at their destination
int const Person::dir() const
{
//Duel ternary
return source_ < destination_ ? 1 : (source_ == destination_ ? 0 : -1);
}