Assignment 09

Due: Friday, Nov. 9, 2018, at midnight (23:23:59.9999+) 100 points

For this assignment, you will submit multiple files containing a program written in C++. Remember, to electronically submit a program for this course, first change to the directory in which the file(s) resides and then type in, at the UNIX prompt, the command:

cssubmit 1570 section_letter assignment_number

Be sure that only the file(s) you want to submit are in that directory - make a directory for every assignment! The submit system runs just the same with multiple files. The submit system will deliver every .cpp and every .h file and every.dat file in the current directory to me. Name your files meaningful names and give them proper extensions.

Foreground: This assignment is going to be a little different from previous assignments. It will work in conjunction with hw #10 in the future. You are laying the groundwork for a bigger program here. Furthermore, this is all about The Krusty Corp., LLC, a fictional global network of Burger Producers and Gastrointestinal Distress Experts.

Leanground: None.

Background: Krusty Burgers are reportedly at the top of the "Most Evil Foods Ever" list, a list of commonly eaten pseudo-foods kept by the Division of Eatable Alternatives To Health, Federal Oversight Organization on Digested Stuff (DEATHFOODS for short). But, no matter ... Krusty and his Krusty Burger restaraunt hold a burger eating contest every year in Springfield. In hw #10, you are going to write a program to simulate that contest. Your program will create an array of customers, have them eat burgers in turn, eating until they either die, quit, or win. Nice, eh? In preparation for this impending carnage, you are going to code up a few classes for this assignment #9. You will also write a main function whose sole purpose is to test the classes you have created. By this we mean that it will declare objects of the types you created and then test their member functions. There is no other purpose to your main function. This type of main is commonly called a driver.

Specifications: In this assignment, you will create two classes. The first is a burger class.

Your burger class is to contain the following:

  • Member variables:

      • ints to represent the number of patties, the number of ozs of bacon, and the number of pickles.

      • a variable to indicate whether or not the burger has cheese.

      • a variable to indicate whether or not the burger has special sauce.

      • a variable to indicate whether or not the burger contains a virulent pathogen.

      • a variable for the name of the burger - as determined by the above contents.

  • Member functions:

      • a constructor to which you can pass values of all the above member variables except the name. It's name should be constructed based on the contents.

      • a default constructor that will

          • set the int member variables to randomly chosen values adhering to the currently agreed upon acceptable values for said members. Note: the currently acceptable values are stated in hw #3 but are hereby modified: it is now allowable to have 4 patties, 4 bacons, and 4 pickles (Yuck!), but YOU will have to invent the names/labels for those burgers. You had better think about modifiers to the burger names given that they have cheese and/or special sauce, also.1

          • 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. This should output all the info about the burger for now. There are lots of ways to do this, some long and some short. You need all the information in order to see if your code is really doing what it's supposed to do. You probably want to make it short and to the point. [Here's one idea: Krusty Blah Blah Blah Burger, (2,1,3,true,true,false) $X.YZ. The values in the parentheses indicate 2-patties,1bacon,3 pickles, has cheese, has sauce, no pathogen.] You will probably modify this in hw 10 to be shorter. For now, output all that information for testing purposes.

  • Notes: Cheese on a burger 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 (U.S. dollars).

      • a member for the customer's weight (in lbs).

      • 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. Or, can pick them at random but without repeats. However you like. You can download a file of names with this: wget http://web.mst.edu/~price/1570/simpson_names.dat You will use this as you did in hw 8.

          • 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 IBUs.2

      • an eat() function which has as a parameter a burger. 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 patties 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

        • *These last two values added only when cheese and sauce are present

      • If the burger eaten has a pathogen, then it will kill the customer.

      • appropriate set and get functions.

      • and, of course, a non-member insertion operator overload. This should display the name, wt, money, cholesterol, and life status. Keep it to one line, such as

      • Marge Simpson weighs 124 lbs, has $45.55, 155 IBU and is ALIVE. (put DEAD or ALIVE in all caps to make it stand out)

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.

We reserve the right to change these classes and the formulas for wt gain and chol gain for hw #10. We have yet to code this up to see what happens; it's hard to guess, but we want it to be fun and interesting.

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 burger to a customer (to eat) 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.

As always, if you have questions, don't hesitate to ask your instructor or the tutor in the lab in the evenings. This is a CS 1570 homework. Do not ask your CS 1580 instructor to clarify these instructions or provide help in "correctly" writing a solution to this homework.

1You probably should not add to the name of a burger if it happens to have a virulent pathogen in it. Customers might be disuaded from purchasing a burger under the name "Krusty Deadly Koronary Burger" or even "Krusty Single Health-Master Garden-Fresh But-May-Kill-You Burger".

2International Bacon Units