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

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: input_string is correctly formatted
* Modifies: turn, currentFloor, targetFloor, angerLevel
* Effects:  Parses input_string to set member variables
Person(string input_string);

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"


 * 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 reached MAX_ANGER), and return true if they did, false otherwise.


* Requires: nothing
* Modifies: outs
* Effects: Prints the infoString of the person NOT including the turn
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