
Let's add the code now to our app.

We're going to start by calculating
the base price of a drink.

The base price is composed of two parts.

The price of the coffee,
which is $5 plus any toppings.

So $1 for whip cream,
or $2 for chocolate.

We're going to take this base price, and

then we're going to multiply it
by the quantity of cups ordered.

That will brings us to
the total order price.

Let's calculate the price for
a sample order,

where the user wants 3 cups of coffee
with whipped cream, like this.

The goal of this course is not to test
your math skills so let's walk through

the calculation together to make
sure that you understand it.

The real goal will be for
you to translate this logic into code.

In this sample order the user wants
3 cups of coffee with whipped cream,

like this.

First, we can start off by calculating
the base price of 1 cup of coffee.

We start with $5 for the coffee cup
plus $1 for the whipped cream topping.

That brings us to $6 per cup.

Then, we need to find
the total order price.

Since the user ordered 3 cups of coffee,
we multiply $6 per cup times 3 cups.

That equals $18 total for
the whole order.

In this sample order,
we have 2 cups of coffee and

each cup has whipped cream topping and
chocolate topping, like this and this.

First, we calculate
the base price of 1 cup.

A cup of coffee costs $5,
and then we add $1 for

whipped cream and $2 for chocolate.

That brings us to a total of 5,
6, 7, 8, $8 per cup.

Then we find the total order price since
the user ordered 2 cups of coffee.

We take the base price of $8 per
cup of coffee times 2 cups and

that brings us to $16 total for
the whole order.

This is what our app should look like.

We can enter in a name,

choose a whipped cream topping and
then change the quantity to 3.

If we hit the Order button,
we expect the price to change to $18.

And there it is.

This is exactly what we
calculated earlier by hand.

If I add the chocolate topping,
change the quantity to 2.

Then the total price becomes $16,

also just like we calculated where
we have $8 per cup of coffee.

Now, go ahead and plan out the steps
that you need to do in order to add this

functionality to our app.

I wrote down the price of
the toppings here for reference.

And here's a screen shot of
what the app should look like

with the adjusted price here.

After you've planned out the steps then
go ahead and implement this in your app.

Then, can you tell me what
method did you end up modifying?