E13: Jamba Juice 2: Implement an order

In Jamba Juice 1, you implemented code for Java Juice menus and menu items. In this WOD you’ll implement code to support customer orders.

Ready? Let’s begin:

  1. Start your timer.

  2. Create a fork of your Jamba Juice 1 JSFiddle to contain the following enhancements.

  3. Create a class called Drink to represent actual Jamba Juice drinks. The Drink constructor takes a MenuItem instance and a string representing the desired size (“small”, “medium”, “large”). Each Drink instance has two properties: price and calories. So, for example, a large Papaya Sunrise drink instance would have a price of $6.55 and 330 calories.

  4. Create a class called “Order” to represent a customer order for one or more drinks. It has an orderDrink(drink) method that adds a Drink instance to your order. The Order class also has an method called totalCost that returns the sum of the prices of the drink instances in that Order.

  5. Exercise your Order class by making an instance, adding at least two drinks, and seeing if the totalCost is correct.

  6. Press the “Update” button to create a URL to refer to your code.

  7. Stop your timer and record your time. Be sure to record it, because you will need your WOD time data when you write your technical essay.

Rx: < 10 min Av: 10 - 14 min Sd: 14 - 18 min DNF: 18+ min


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

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 on the Schedule page, 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 the email with all required data before the due date. Your code does not have to run perfectly for you to receive full credit. However, if you do not repeat each practice WOD until you can finish it successfully in at least AV time, you are unlikely to do well on the in-class WOD. To reduce the stress associated with this course, I recommend that you repeat each practice WOD as many times as necessary to achieve at least AV before its due date.