Divide up into teams of two. You will each complete this WOD on your own computer and create your own JSFiddle to hold your work, but you must work “synchronously”–i.e. both of you must type each line of code or perform each action at the same time, and thus you will both complete this WOD at the same time. This means you must talk to each other continuously about what you are doing.
The goal of this WOD is to implement a class that keeps track of the total calories, fat, and sodium in a Burger King order and notifies you when your order has exceeded the recommended daily maximum for a sedentary college student (i.e. 2,000 calories, 70 grams fat, 2300 mg sodium).
Here is some code to define objects containing reference values for various BK items:
Now create a class called BKMenu whose constructor accepts the bkItems data structure and saves it. The BKMenu class should also store the recommended daily maximum for calories, fat, and sodium.
BKMenu implements an add() function that accepts a string indicating the item ordered, which will be one of the fields in the bkItems data structure. For example, “cokeLarge”, “whopper”.
Whenever the add() function is called, if the recommended daily maximum for calories, fat, or sodium is now exceeded for that order, the function should print out the total along with a message to the console for that value.
For example:
Ready? Let’s begin:
Login to JSFiddle.
Copy and paste the bkItems variable definition into JSFiddle so that data is available.
Create a Javascript class called “BKMenu”. It provides an add() function that takes a string and updates internal counters appropriately. When thresholds for calories, fat, or sodium are exceeded, it prints out a message to the console.
Informally test your program by running it and inspecting the output.
When you are confident the function works correctly, press “Save” to create a URL to your JSFiddle.
Raise your hand to let me know you have finished.
Rx: < 8 min Av: 8-12 min Sd: 12-15 min DNF: 15+ min
We will go over the solution to this problem in class.
https://bit.ly/3OT4Yfi