Due: Wednesday, April 21, 2021 at noon 100 points
Foreground: For this assignment, you may work with a partner. That is, you can work in a group of two (2). If you choose to do so, here are the rules:
You submit only under one name; not twice, once for each name. But to be sure you both get credit, be sure that both your names are in all the comment headers.
Your partner and you must have the same instructor - both in Price's section(s) or both in Wong's section(s).
You both do the work. Both of you will code and both of you will document the code. NO SPONGING OFF YOUR PARTNER.
And remember that this program will represent 10% of your final grade.
Background: Bart’s living life good. He’s got a logistically funded gambling ring (thanks to you) and a wildly popular high-water pants shop (also thanks to you, and oddly enough, you haven’t seen a dollar). Bart was sitting back relaxing at his mansion sipping some Duff Soda when the local “business man”, Cletus, came up to Bart with a business opportunity. Bart, excited to make money, jumps at the offer. Cletus has an abundance of processed meats (ok, it's actually roadkill) he thinks would make good fast-food sandwiches. To promote the opening of his eating establishment, Bart decides to hold an eating contest.
Bart takes one look at the roadkill ingredients and realizes that nobody is going to want to eat that stuff unprocessed. So, Bart does what the rest of the world does and grinds it up into hot dogs that Cletus quickly dubs “hawt dawgs”. So it’ll be a hawt dawg eating contest for the opening of “Cletus’s Famous Road Kill Cafe”.
Specifications: You will have to define the hawt dawg first in a class which will contain:
Member variables
· ints to represent the number of different animals in the hawt dawg, how many ounces of onion are on the hawt dawg, and how many pickles are on the hawt dawg
· a variable to indicate whether or not the hawt dawg contains relish
· a variable to indicate whether or not the hawt dawg contains cheese
· a variable to indicate whether or not the hawt dawg contains a virulent pathogen
· a variable for the cost of the hawt dawg
Member functions:
· a constructor to which you can pass values of all the above member variables except cost
· a default constructor that will
o set the int member variables to randomly chosen values adhering to the currently agreed upon maximum acceptable values for said members: 4 animals, 4 oz of onion, and 4 pickles (Yuck!). A minimum of 0 in each case.
o Randomly set whether the hawt dawg contains a virulent pathogen. This should be true only 10% of the time.
o Randomly set whether the hawt dawg contains relish or cheese. This should be true only 50% of the time for both, independently.
· Appropriate set and get functions only if necessary!
· a non-member insertion operator overloaded
Note: Each animal costs $0.75, each oz. of onion is $0.50, each pickle slice is $0.25, the bread is $0.50, relish on a dawg costs an extra $.25, cheese on a dawg is an extra $0.50. A virulent pathogen is free of change, however you WILL pay in the end.
You will also want a Customer class that contains the following:
Member Variables:
· a member for the customer’s name
· a member for their “local monetary holdings”, i.e cash in pocket
· a short to indicate the customer’s health value in the range of 0 to 100 (0 indicates death)
· a integer member for the person's weight (in the range 70 to 300, inclusive)
· a variable to indicate whether or not the customer is alive
Member functions:
· A default constructor that will:
o name the customer by drawing a name from a file of names. You can have your code pick names in the order that they appear in the file; when the list is exhausted, begin from the first name again. We will supply a file of names like we did in the last assignment.
o randomly assigns them monetary holdings between $25 and $75, inclusive; randomly assigns weight as described above.
o makes them living
o randomly assigns a health value between 1 and 100, inclusive. (A value of 0 is synonymous with death and should not be assigned by the constructor.)
· An eat() function which has as a parameter a hawt_dawg. The function should diminish the financial holdings of the customer by the price of the dawg passed and add 4 lbs to their weight.
A hawtdawgmeister class is to contain the following:
Member variables:
· a name (presumably instantiated w/ "Cletus")
· monetary holdings
Member functions:
· a constructor that accepts a string for the object's name and monetary holdings.
· an overloaded += operator that takes a float (representing money) and adds it to the Hotdawgmeister’s money. So, you might have Cletus += 5; meaning Cletus just made $5.
· an overloaded -= operator (for similar purposes).
You may have other members/functions, but that's up to you to decide.
Details of Stuff: The contest will proceed as follows: There will be as many rounds as is necessary, ending when there are no contestants still eating hawt dawgs1. You will start with an array of 15 customers; these are the contestants. In each round, every contestant is fed a hawt dawg if (s)he can eat it. Being able to eat a hawt dawg is determined by whether or not the contestant is alive, can pay for the dawg, and is still a contestant. After the start of the contest, a contestant can become a non-contestant by either dying or angering the hawtdawgmeister so that (s)he disqualifies him/her (this is described later). When a contestant eats a hawt dawg, (s)he pays the hawtdawgmeister -- ok, I'm going to call him Cletus and you really should too -- the cost of the hawt dawg. Now things get interesting. After eating a hawt dawg, their health value is decremented by 2 points. Also, if a dawg with a virulent pathogen is consumed, then the customer will either die or sicken and vomit. To determine which, "roll a 100-sided die"; if the value that comes up is greater than the customer's health value, they die; if the value is equal to or less than his/her health value, they vomit and their health is halved. If a contestant (let's call him Alpha) vomits, then there is a 50% chance that his neighbors (in the array) will also vomit. So, if Alpha vomits, your code will have to first walk down the array of contestants determining (with a 50% chance) if the next contestant vomits....and if so, then the next....and if so, then the next....until you reach the bottom end of the array or someone doesn't vomit or the next guy/gal is dead. (Note: even alive non-contestants can puke.) After walking down the array, you will need to walk up the array doing the same until reaching the top of the array or someone doesn't vomit or you reach a dead contestant (thank God dead guys don't puke!). Now, in both cases (going down and going up), if the chain-reaction vomiting ends by someone just not vomiting, then that contestant has a 70% chance of starting a food fight. This means that (s)he throws a hawt dawg at another contestant or Cletus. Their target is chosen at random and can include themselves (stupid, yes, how stupid can you get - eating roadkill at Cletus's restaurant!). When another contestant is hit by a hawt dawg, they have a 80% chance of continuing the fight by randomly choosing a target and throwing a hawt dawg. Each thrown dawg has to be paid for by the thrower, but the thrower's health increments by 2 points (because it feels soooo good to throw food!). The food fight stops when someone decides not to throw, can't afford the hawt dawg to throw, a dead contestant is the target, or if Cletus is hit. If Cletus is hit, he gets angry and disqualifies the guy who hit him with a hawt dawg, and robs the thrower of all his cash. After a food fight ends, continue checking for pukers in the array. Then, on to the next round of feeding!
So, to make it clear, you will have a contestant eat a dawg and react to it completely (no reaction or dying or puking or released anger management) before the next contestant in line eats.
Note: The above descriptions of these classes are bare minimum. You may find it necessary or desirable to add relevant member variables and/or private member functions (to help make the code better). Also, since you will be displaying dollar amounts, it's bad form to have $3.50 come out as $3.5. So, put this code at the top of your main after declarations and it will force exactly two decimal places to be shown always.
cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2);
Output Formattttttting: To make the output of this simulation (of real life!), the format of your output is important. Please make your output look like this:
Begin the Contest!!!
The Contestants are
Marge 134 lbs ...
Barney 56 lbs ...
etc
------------------------ ROUND #1 -------------------
Marge eats a dawg wt 138, health value 44 ... ALIVE
Barney eats a dawg wt 60, health value 35 ... DEAD
Wiggum eats a dawg wt 300, health value 77 ... ALIVE and barfs!
Bart barfs GAGGGG! BLAHHHCCCH
Lisa barfs BARBARA STREISAND!!
Lenny doesn't barf
Lenny tosses dawg at Wiggum
Wiggum tosses dawg at Homer
Homer tosses dawg at Homer
Bart eats a dawg wt 212, health value 55 .... ALIVE
ETC
-------------------------ROUND #2 ---------------------
Marge eats .........
ETC
Notice that each person who barfs yells something. Like...yeah. Wouldn't you? So, you can randomly generate a "barfing statement" however you see fit. If you want to use a constant array of strings to choose from or use a file, go for it.
File of Names: As you have seen in past assignments, you can download a file from me with names so you don't have to create the file. You can assume one name per line without whitespace in the name. As before, you are not to open the file and count the names. But you can have your code do that.
wget http://web.mst.edu/~price/1570/names.dat
Stuff: We have outlined what you need to do. But we have left out a lot of detail. You have to make a lot of decisions, and they are yours to make. You can add other classes if you like, add other functions to the above classes, etc. One thing we don't allow is that you make every class a friend of the others so that you don't have to deal with accessibility as you should. Make your code good! As a wise word of warning, you had better use constants fully and wisely since we very well may change the parameters of this simulation (of real life). As an example, we just might later change the probability of starting a food fight to 60%, say. You don't want to have to search your code for that.
As always....if you have questions, just ask.
1Let's make this clear: if a round proceeds during which nobody eats a dawg, then the contest ends.