Skip to content

Burger Options & Toppings


Separate the "toppings" and related pricing from the core Burger pricing.

Make Default a Regular Burger

First, we'll make the default burger a regular burger, so that it's no longer specified as an option.

  • Replace the existing regularBurgerCosts5 test in BurgerTest with the following:

    public void burgerWithNoToppingsCosts5() throws Exception {
      Burger burger = new Burger();
      int price = burger.price();
  • The above test will not compile because the "no argument" constructor doesn't exist. Add a constructor that takes no arguments and has no code.

  • Run the test, it should fail with a NullPointerException

  • Modify the Burger class so that it passes

    • Are there any other tests you could write?