Lab 4 - Burger Multiple Toppings

In the last lab, we moved the responsibility for the pricing of a topping to the BurgerToppings enum. In this lab, you will allow the burger to have multiple toppings.

Make sure ALL tests PASS before you start

  1. Write a test for adding a topping to a "core" burger, something like the following:

    Burger burger = new Burger();
    burger.addTopping(BurgerToppings.CHEESE);
    assertThat(burger.price()).isEqualTo(6);
    
    Make sure this test FAILS

  2. What Java collection class would be appropriate to keep track of the multiple toppings: Map? Set? List? Why?

    • Remember generics: you will have a collection of BurgerToppings instead of just a single one.
  3. Make the test PASS.

  4. Write a few more tests and make sure that you cover:

    • Adding no toppings: 5
    • Adding single topping of cheese: 6
    • Adding single cheese and single bacon: 7
    • Adding 2 (two) cheese toppings: 7

    Make sure ALL tests pass

  5. Increase price of Bacon to 2

    • Modify your test first
    • Then make the change to make the test pass

You are done when ALL tests pass.