E12: Jamba Juice 1: Implement the Menu

As of Summer, 2016, the Jamba Juice store at the Manoa campus had the following menu (you can click on the image to view it full size):

picture

Each Jamba Juice menu item can be represented as follows:

For the first Jamba Juice assignment, you will create Javascript classes to represent four menu items and use them to define another class called Menu.

Ready? Let’s begin:

  1. Start your timer.

  2. Login to JSFiddle and create a new JSFiddle for your code.

  3. Create a class called “MenuItem”, with a constructor that takes:

    • a name (string),
    • an array of ingredients (strings),
    • an object whose keys are small, medium, large and whose values are the associated prices,
    • another object with the above keys and the associated calories
  4. Create instances of MenuItem for PapayaSunrise, PeachPerfection, StrawberryDragon, and StrawberryWhirl. Use the console to check that they represent their item correctly.

  5. Create a class called “Menu” which provides access to one or more MenuItem instances. It has:

    • an addMenuItem() method to add a MenuItem subclass to the menu.
    • a findMenuItems(ingredient) method that takes an ingredient string and returns all of the MenuItems that contain that ingredient.
  6. Create an instance of the Menu class, add the four MenuItem instances to it, and use the findMenuItems() method to find the two MenuItems that are made with mangos.

  7. Press the “save” button to create a URL to refer to your code.

  8. Stop your timer and record your time for this attempt. Be sure to record all your WOD times, because you will need them when you write your technical essay.

Rx: < 21 min Av: 21 - 25 min Sd: 25 - 30 min DNF: 30+ min

Demonstration

Once you’ve finished trying the WOD for the first time, watch me do it.

Note that this video uses an older version of JSFiddle, which did not include the built-in console. Otherwise everything is still the same.

Standard WOD Caveats

You’ll learn significantly less from watching me solve the WOD if you haven’t attempted the WOD yourself first.

While it’s an achievement to finish the WOD no matter how long it takes, you might experience “diminishing returns” if you work longer than the DNF time. Thus, it is usually strategic to stop working at the DNF time and watch my solution.

After watching my solution, I recommend that you repeat the WOD if you have not achieved at least Av performance. If so, be sure to:

Feel free to keep trying until you make Rx if that’s of interest to you.

Submission Instructions

By the time and date indicated in Laulima, submit this assignment via Laulima.

Your submission should contain:

You will receive full credit for this practice WOD as long as you have attempted it at least once and submitted your work on Laulima with all required data before the due date. Your code does not have to run perfectly for you to receive full credit.