Final Project

Due: December 3rd, 2021 12:00pm


For this assignment, you will submit multiple C++ compilable files containing a program written in C++. For every function, you must have the proper function documentation as well! We suggest (strongly) that you make a directory for every assignment! Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work. Note: You are allowed to work with at most one other person on this final project who needs to be in the same section as you are. Make sure to put both of your names in the header of all the C++ files. Only one of you needs to submit to GitLab.

Background

While you are working hard to try to get as many dates as possible in the big city, a group of skillful robbers is also working hard, hoping to add more funds to their retirement accounts by deciding to rob a rich bank together1. However, during their attempt, an incident occurred and caused all of the valuable jewels in the bank to end up scattering all over the city streets. The robbers are now rushing to recollect their prize, but of course the bank alarms sounded and cops are now just showing up too. You know that an epic chase is about to happen in the city grid, and you just couldn’t resist watching it through your apartment window even though your love interest has been calling your mobile more than ten times now…

Specifications

City Class

This class should have the following attribute(s):

Jewel Class

This class should have the following attributes:

The Robber Class

The Robber class should be created to serve as the base class for representing a basic robber type.

The Ordinary_Robber Class The Greedy_Robber Class The Police Class

Overall Program Flow

  1. The simulation of the chase should begin by first creating the city grid of dimension 10 x 10.
  2. Randomly scatter 47 jewels in the city grid and notate them with ‘J’
    • Each cell in the grid can be occupied by only one jewel.
    • A possible way to code this is for the jewels to be created dynamically whenever a robber picks one up.
  3. Create one police, two ordinary robbers, and two greedy robbers. Randomize their initial locations in the grid and notate them with ‘P’ and ‘R’ correspondingly.
  4. Print out the initial state of the city grid nicely (you might want to create a function to handle this specifically).
  5. Let the chase begin! Each turn consists of having the ordinary robbers move first, followed by the greedy robbers, and then the police.
    • Remember, a robber stops moving once they get caught.
  6. At the end of each turn, print out the state of the city grid nicely.
  7. We will do a maximum of 30 turns. If the police failed to catch all the robbers in the final chase, then all the robbers get to run away freely, but the confiscated jewels should remain with the police.
    • The robbers could also win if they managed to collectively pick up enough jewels with a net worth of $2022 at any point during the chase.
    • If this happens, then the police will release all the arrested robbers as well since the bribe is too tempting. Also, the police get to keep all the confiscated jewels too.
  8. When the chase terminates, print out a summary of the chase outcome. For example, the format should be:
    Summary of the chase:
    		The robbers wins the chase because maximum turns (50) have been reached  
    		Police id: 1
    			Confiscated jewels amount: $512 
    			Final number of robbers caught: 0 
    		Ordinary Robber id: 1 
    			Final number of jewels picked up: 5
    			Total jewel worth: $91
    		Ordinary Robber id: 2 
    			Final number of jewels picked up: 0 
    			Total jewel worth: $0
    		Greedy Robber id: 3 
    			Final number of jewels picked up: 22
    			Total jewel worth: $750
    		Greedy Robber id: 4   
    			Final number of jewels picked up: 8
    			Total jewel worth: $240
              

Notes

  1. As a reminder, trying to get rich by robbing a bank is ALWAYS a bad idea. It is MUCH safer to just get a job as a programmer.
  2. For all the data members in the class definitions, it is up to you to determine their proper access levels (i.e. public vs protected vs private).
  3. It is also your sole responsibility to determine the best return types and parameters for the functions specified in this assignment.
  4. You may create additional member attributes in the classes if proven to be helpful. Additional functions may also be added for improving the code organization and readability.
  5. Set the random seed to be 85 for this assignment.
  6. When printing the city grid, if two robbers happen to be in the same cell, then simply print ‘R’.
  7. If a robber gets arrested, then the remaining robbers can still continue the chase.