• 0:00 - 0:01
Let's add the code now to our app.
• 0:01 - 0:06
We're going to start by calculating
the base price of a drink.
• 0:06 - 0:08
The base price is composed of two parts.
• 0:08 - 0:11
The price of the coffee,
which is \$5 plus any toppings.
• 0:11 - 0:13
So \$1 for whip cream,
or \$2 for chocolate.
• 0:13 - 0:16
We're going to take this base price, and
• 0:16 - 0:19
then we're going to multiply it
by the quantity of cups ordered.
• 0:19 - 0:21
That will brings us to
the total order price.
• 0:23 - 0:25
Let's calculate the price for
a sample order,
• 0:25 - 0:29
where the user wants 3 cups of coffee
with whipped cream, like this.
• 0:29 - 0:32
The goal of this course is not to test
your math skills so let's walk through
• 0:32 - 0:35
the calculation together to make
sure that you understand it.
• 0:35 - 0:39
The real goal will be for
you to translate this logic into code.
• 0:39 - 0:43
In this sample order the user wants
3 cups of coffee with whipped cream,
• 0:43 - 0:44
like this.
• 0:44 - 0:48
First, we can start off by calculating
the base price of 1 cup of coffee.
• 0:48 - 0:53
plus \$1 for the whipped cream topping.
• 0:53 - 0:55
That brings us to \$6 per cup.
• 0:55 - 0:58
Then, we need to find
the total order price.
• 0:58 - 1:03
Since the user ordered 3 cups of coffee,
we multiply \$6 per cup times 3 cups.
• 1:03 - 1:07
That equals \$18 total for
the whole order.
• 1:07 - 1:10
In this sample order,
we have 2 cups of coffee and
• 1:10 - 1:15
each cup has whipped cream topping and
chocolate topping, like this and this.
• 1:15 - 1:17
First, we calculate
the base price of 1 cup.
• 1:18 - 1:21
A cup of coffee costs \$5,
and then we add \$1 for
• 1:21 - 1:24
whipped cream and \$2 for chocolate.
• 1:24 - 1:29
That brings us to a total of 5,
6, 7, 8, \$8 per cup.
• 1:29 - 1:33
Then we find the total order price since
the user ordered 2 cups of coffee.
• 1:33 - 1:37
We take the base price of \$8 per
cup of coffee times 2 cups and
• 1:37 - 1:40
that brings us to \$16 total for
the whole order.
• 1:41 - 1:43
This is what our app should look like.
• 1:44 - 1:45
We can enter in a name,
• 1:45 - 1:49
choose a whipped cream topping and
then change the quantity to 3.
• 1:49 - 1:53
If we hit the Order button,
we expect the price to change to \$18.
• 1:54 - 1:55
And there it is.
• 1:55 - 1:58
This is exactly what we
calculated earlier by hand.
• 1:58 - 2:02
If I add the chocolate topping,
change the quantity to 2.
• 2:02 - 2:04
Then the total price becomes \$16,
• 2:04 - 2:09
also just like we calculated where
we have \$8 per cup of coffee.
• 2:09 - 2:12
Now, go ahead and plan out the steps
that you need to do in order to add this
• 2:12 - 2:14
functionality to our app.
• 2:14 - 2:16
I wrote down the price of
the toppings here for reference.
• 2:16 - 2:19
And here's a screen shot of
what the app should look like
• 2:19 - 2:21
• 2:21 - 2:25
After you've planned out the steps then
• 2:25 - 2:28
Then, can you tell me what
method did you end up modifying?
タイトル：

more » « less
Video Language:
English
Team:
Udacity
プロジェクト：
UD837 - Android for Beginners
Duration:
02:28
 Udacity Robot edited 英語(米国) subtitles for 13-18 Adjust Price With Toppings Udacity Robot edited 英語(米国) subtitles for 13-18 Adjust Price With Toppings Cogi-Admin edited 英語(米国) subtitles for 13-18 Adjust Price With Toppings

# English subtitles

## 改訂 Compare revisions

• API
Udacity Robot
• API
Udacity Robot
• API