-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPerson.cpp
More file actions
executable file
·86 lines (68 loc) · 1.64 KB
/
Copy pathPerson.cpp
File metadata and controls
executable file
·86 lines (68 loc) · 1.64 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright 2023 University of Michigan EECS183
*
* Person.cpp
* Project UID 28eb18c2c1ce490aada441e65559efdd
*
* <#Names#>
* <#Uniqnames#>
*
* Final Project - Elevators
*/
#include "Person.h"
#include <iostream>
#include <cmath>
#include <sstream>
using namespace std;
Person::Person(string inputString) : Person() {
string data = inputString;
stringstream s(data);
//read in turn value
s >> turn;
//junk to read and discard the letters
char junk;
s >> junk;
//read in the remaining data
s >> currentFloor >> junk >> targetFloor >> junk >> angerLevel;
}
bool Person::tick(int currentTime) {
if ((currentTime % TICKS_PER_ANGER_INCREASE) == 0){
angerLevel++;
}
if (angerLevel >= MAX_ANGER){
return true;
}
else{
return false;
}
}
void Person::print(ostream &outs) {
outs << "f" << currentFloor << "t" << targetFloor
<< "a" << angerLevel;
}
//////////////////////////////////////////////////////
////// DO NOT MODIFY ANY CODE BENEATH THIS LINE //////
//////////////////////////////////////////////////////
Person::Person() {
turn = 0;
currentFloor = 0;
targetFloor = 0;
angerLevel = 0;
}
int Person::getTurn() const {
return turn;
}
int Person::getCurrentFloor() const {
return currentFloor;
}
int Person::getTargetFloor() const {
return targetFloor;
}
int Person::getAngerLevel() const {
return angerLevel;
}
ostream& operator<< (ostream& outs, Person p)
{
p.print(outs);
return outs;
}