Specifications: In this assignment, you will create two classes. The first is a sammich class.
Your sammich class is to contain the following:
Member variables:
ints to represent the number of different animals on the sammich, the number of ozs of bacon, and the number of pickles.
a variable to indicate whether or not the sammich has cheese.
a variable to indicate whether or not the sammich has special sauce.
a variable to indicate whether or not the sammich contains a virulent pathogen.
a variable for the cost of the sammich
Member functions:
a constructor to which you can pass values of all the above member variables except cost.
a default constructor that will
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 bacon, and 4 pickles (Yuck!). A minimum of 0 in each case.
randomly set the bool members of the class. For having cheese or special sauce, it should be a 50-50 shot of having them. But for the pathogen, your code should assign true only 10% of the time.
appropriate set and get functions.
a non-member insertion operator overload.
Notes: Each animal costs $0.75, each oz. of bacon costs $0.50, each pickle slice is $0.25, the bread is $0.50 (total for both pieces), cheese on a sammich costs an extra $.25, special sauce is $.10. A virulent pathogen is free of charge, though you WILL pay in the end.
Your customer class has the following:
Member variables:
a member for the customer's name.
a member for their "local monetary holdings" i.e. cash in their pockets.
a member for the customer's weight.
a short to represent their cholesterol level (this value should normally fall between 30 and 300, inclusive).
a variable to indicate whether or not the customer is alive.
Member functions:
a default constructor that will
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. Make a file of names and put 15 names from "The Simpsons" in it.
randomly assigns them monetary holdings between $25 and $75, inclusive.
randomly assigns their weight between 90 lbs and 250 lbs, inclusive.
makes them living.
randomly assigns a cholesterol level between and including 30 and 300.
an eat() function which has as a parameter a sammich. The function should diminish the financial holdings of the customer by the price of the burger passed, increase the customer's cholesterol according to this function:
chol gain = 2.5 * B + (PI/2) * P + wt/((K + 1)*10),
where B is the number of oz of bacon
P is the number of animals
K is the number of piKles
and increase the weight of the customer according to this formula:
wt gain = 0.5*P2 + (1/8)*B2 - K/4 + C + S,
where B, P, and K are as above and
C is the gain attributed to cheese, currently determined to be 1.2
S is the gain attributed to special sauce, currently determined to be 2.1
If the sammich eaten has a pathogen, then it will kill the customer. If the customer doesn't have the money for the sammich, s/he won't eat() the function, but will output a message to the screen: "I can't afford to eat."
and, of course, a non-member insertion operator overload.
Note: No customer is to be allowed to have a weight that is negative.
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). You should NOT add other public functions. 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.
We reserve the right to change these classes and the formulas for wt gain and chol gain for hw #10.
Your driver (that's your main function) should declare objects of the types you have defined. It should test the member functions, including the constructors. After declaring these objects, output them to see their initial states. Pass a sammich to a customer and output the customer to see the effects. There should be no interaction with the user of the program. The driver is there merely to test your coding of the classes. Make the testing thorough.