# Person.cpp

## Overview

Person is a class declared in Person.h and is responsible for representing a single person inside the building. Each Person will reside on a Floor, slowly getting angrier until they are picked up by an Elevator.

## Member Data

• turn is an int that stores the turn on which a Person will be spawned
• angerLevel is an int representing how angry a Person is. Once this reaches MAX_ANGER, the Person will explode. This will deduct points from the overall score in Game.
• currentFloor is an int representing the floor a Person is currently on.
• targetFloor is an int representing which floor a Person is trying to reach.

## Member Functions

Many member functions have been written for you. Please refer to their RME’s for use reference.

You will be writing the implementation for the following function:

/*
* Requires: inputString is correctly formatted
* Modifies: turn, currentFloor, targetFloor, angerLevel
* Effects:  Parses input_string to set member variables
*           An example of input_string is "7f4t8a3".
*/
Person(string inputString);


Person has a single non-default constructor which parses a special string to initialize a Person’s data members. Refer here in section “The ticks and locations where people will spawn” for details on how the input_string will be formatted. These strings will be how the Person will be stored in game.in, so we will use this constructor to parse each Person’s information.

You may find it useful to use the C++ stringstream class in this function. A stringstream allows you to use >> and << on string input, like in this example:

#include <sstream>

string str = "123abc";
stringstream ss(str);
int x;
ss >> x;
string s;
ss >> s;

// x now contains the integer 123
// s now contains "abc"


### tick

/**
* Requires: nothing
* Modifies: angerLevel
* Effects:  Every TICKS_PER_ANGER_INCREASE, this function increases the
*           person's anger level by 1. If, after increasing, the person
*           has an anger level of MAX_ANGER, the function will return
*           true. If the person has an anger level less than MAX_ANGER,
*           the function will return false.
*/
bool tick(int currentTime);


tick is the function that advances the game one turn. In the context of Person, this involves updating their angerLevel at certain preset intervals. Specifically, we do the following:

1. If the currentTime is divisible by TICKS_PER_ANGER_INCREASE, then we will increment the person’s angerLevel.
2. Determine if the person exploded (their angerLevel is greater than or equal to MAX_ANGER), and return true if they did, false otherwise.

### print

/**
* Requires: nothing
* Modifies: outs
* Effects:  Prints the infoString of the person NOT including the turn
*
* Example:  Person p("7f4t8a3");
*           cout << "\nThe person you just entered is: ";
*           p.print(cout);
*
*           This will print "f4t8a3"
*/
void print(ostream &outs);


This function prints the infoString of the person. It does NOT include the turn. Refer here in section “The ticks and locations where people will spawn” for details on how the infoString will be formatted. Here is an example:

Person p("7f4t8a3");
p.print(cout);  // prints f4t8a3