Building is a class declared in Building.h and is responsible for containing the full state of the game. It controls all of the Elevators and Floors by performing the Moves and adding the Person objects that are presented to it. There is a single instance of a Building class that will be used by the Game class to track the state of the assets while the game is played.

Member Data

Member Functions

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

You will be writing the implementations for the following functions:


* Requires: move is a valid move
* Modifies: The private member variables of building
* Effects: Increments time and calls update() on the input move.
*          Then, ticks all of the elevators with the new time.
*          Next, ticks all of the building floors, keeping track of new
*          exploded people.
*          Returns the total number of people that exploded in this tick
int tick(Move move);

tick is the function that advances the game one turn. During each turn, we give the player the opportunity to make one Move, which comes in as an argument to this function. Overall, this function is responsible for:

  1. Updating the time
  2. Applying the Move to the building and updating the appropriate state.
  3. Calling tick with the new time on all the assets in the building.
  4. Collecting and returning the information about the People who exploded that turn for scoring purposes


* Requires: move is a valid move
* Modifies: The building member variables affected by the move
* Effects: Applies the move to the building:
*          * If the move is a Pass Move, nothing happens
*          * If the move is a Pickup Move, copies the list of people to
*            pickup into an array, and calls removePeople() on the
*            appropriate floor
*          * For both Pickup Moves and Service Moves, the appropriate
*            elevator should be sent to service the targetFloor of the move
void update(Move move);

This is one part of a tick, during which we take the incoming Move and use it to update the appropriate Floor or Elevator. (See the section on Move for more details) for definitions of Pass Move, Pickup Move, and Service Move.


* Requires: newPerson is a valid Person object
* Modifies: A floor in the building
* Effects:  Adds a person to the Floor corresponding to startingFloor
*           of the event
void spawnPerson(Person newPerson);

Each Person corresponds to a person appearing on a Floor. So, to process a person, we call floor.addPerson() on the Floor where this Person appeared.