Burger Options & Toppings¶
Goal¶
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 inBurgerTest
with the following:@Test public void burgerWithNoToppingsCosts5() throws Exception { Burger burger = new Burger(); int price = burger.price(); assertThat(price) .isEqualTo(5); }
-
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?