[Script Info]
Title:
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.46,0:00:01.32,Default,,0000,0000,0000,,Let's add the code now to our app.
Dialogue: 0,0:00:01.32,0:00:05.71,Default,,0000,0000,0000,,We're going to start by calculating\Nthe base price of a drink.
Dialogue: 0,0:00:05.71,0:00:07.91,Default,,0000,0000,0000,,The base price is composed of two parts.
Dialogue: 0,0:00:07.91,0:00:11.31,Default,,0000,0000,0000,,The price of the coffee,\Nwhich is $5 plus any toppings.
Dialogue: 0,0:00:11.31,0:00:13.42,Default,,0000,0000,0000,,So $1 for whip cream,\Nor $2 for chocolate.
Dialogue: 0,0:00:13.42,0:00:15.52,Default,,0000,0000,0000,,We're going to take this base price, and
Dialogue: 0,0:00:15.52,0:00:19.36,Default,,0000,0000,0000,,then we're going to multiply it\Nby the quantity of cups ordered.
Dialogue: 0,0:00:19.36,0:00:21.08,Default,,0000,0000,0000,,That will brings us to\Nthe total order price.
Dialogue: 0,0:00:22.64,0:00:24.93,Default,,0000,0000,0000,,Let's calculate the price for\Na sample order,
Dialogue: 0,0:00:24.93,0:00:28.77,Default,,0000,0000,0000,,where the user wants 3 cups of coffee\Nwith whipped cream, like this.
Dialogue: 0,0:00:28.77,0:00:32.41,Default,,0000,0000,0000,,The goal of this course is not to test\Nyour math skills so let's walk through
Dialogue: 0,0:00:32.41,0:00:35.21,Default,,0000,0000,0000,,the calculation together to make\Nsure that you understand it.
Dialogue: 0,0:00:35.21,0:00:38.86,Default,,0000,0000,0000,,The real goal will be for\Nyou to translate this logic into code.
Dialogue: 0,0:00:38.86,0:00:42.91,Default,,0000,0000,0000,,In this sample order the user wants\N3 cups of coffee with whipped cream,
Dialogue: 0,0:00:42.91,0:00:44.00,Default,,0000,0000,0000,,like this.
Dialogue: 0,0:00:44.00,0:00:48.07,Default,,0000,0000,0000,,First, we can start off by calculating\Nthe base price of 1 cup of coffee.
Dialogue: 0,0:00:48.07,0:00:53.18,Default,,0000,0000,0000,,We start with $5 for the coffee cup\Nplus $1 for the whipped cream topping.
Dialogue: 0,0:00:53.18,0:00:55.39,Default,,0000,0000,0000,,That brings us to $6 per cup.
Dialogue: 0,0:00:55.39,0:00:57.58,Default,,0000,0000,0000,,Then, we need to find\Nthe total order price.
Dialogue: 0,0:00:57.58,0:01:02.88,Default,,0000,0000,0000,,Since the user ordered 3 cups of coffee,\Nwe multiply $6 per cup times 3 cups.
Dialogue: 0,0:01:02.88,0:01:07.01,Default,,0000,0000,0000,,That equals $18 total for\Nthe whole order.
Dialogue: 0,0:01:07.01,0:01:09.65,Default,,0000,0000,0000,,In this sample order,\Nwe have 2 cups of coffee and
Dialogue: 0,0:01:09.65,0:01:14.84,Default,,0000,0000,0000,,each cup has whipped cream topping and\Nchocolate topping, like this and this.
Dialogue: 0,0:01:14.84,0:01:16.86,Default,,0000,0000,0000,,First, we calculate\Nthe base price of 1 cup.
Dialogue: 0,0:01:18.15,0:01:21.09,Default,,0000,0000,0000,,A cup of coffee costs $5,\Nand then we add $1 for
Dialogue: 0,0:01:21.09,0:01:23.62,Default,,0000,0000,0000,,whipped cream and $2 for chocolate.
Dialogue: 0,0:01:23.62,0:01:28.54,Default,,0000,0000,0000,,That brings us to a total of 5,\N6, 7, 8, $8 per cup.
Dialogue: 0,0:01:28.54,0:01:32.83,Default,,0000,0000,0000,,Then we find the total order price since\Nthe user ordered 2 cups of coffee.
Dialogue: 0,0:01:32.83,0:01:37.14,Default,,0000,0000,0000,,We take the base price of $8 per\Ncup of coffee times 2 cups and
Dialogue: 0,0:01:37.14,0:01:40.20,Default,,0000,0000,0000,,that brings us to $16 total for\Nthe whole order.
Dialogue: 0,0:01:41.23,0:01:42.58,Default,,0000,0000,0000,,This is what our app should look like.
Dialogue: 0,0:01:43.64,0:01:44.77,Default,,0000,0000,0000,,We can enter in a name,
Dialogue: 0,0:01:44.77,0:01:49.01,Default,,0000,0000,0000,,choose a whipped cream topping and\Nthen change the quantity to 3.
Dialogue: 0,0:01:49.01,0:01:52.84,Default,,0000,0000,0000,,If we hit the Order button,\Nwe expect the price to change to $18.
Dialogue: 0,0:01:54.08,0:01:55.18,Default,,0000,0000,0000,,And there it is.
Dialogue: 0,0:01:55.18,0:01:58.45,Default,,0000,0000,0000,,This is exactly what we\Ncalculated earlier by hand.
Dialogue: 0,0:01:58.45,0:02:01.68,Default,,0000,0000,0000,,If I add the chocolate topping,\Nchange the quantity to 2.
Dialogue: 0,0:02:01.68,0:02:04.03,Default,,0000,0000,0000,,Then the total price becomes $16,
Dialogue: 0,0:02:04.03,0:02:08.74,Default,,0000,0000,0000,,also just like we calculated where\Nwe have $8 per cup of coffee.
Dialogue: 0,0:02:08.74,0:02:12.05,Default,,0000,0000,0000,,Now, go ahead and plan out the steps\Nthat you need to do in order to add this
Dialogue: 0,0:02:12.05,0:02:13.59,Default,,0000,0000,0000,,functionality to our app.
Dialogue: 0,0:02:13.59,0:02:16.30,Default,,0000,0000,0000,,I wrote down the price of\Nthe toppings here for reference.
Dialogue: 0,0:02:16.30,0:02:18.91,Default,,0000,0000,0000,,And here's a screen shot of\Nwhat the app should look like
Dialogue: 0,0:02:18.91,0:02:20.80,Default,,0000,0000,0000,,with the adjusted price here.
Dialogue: 0,0:02:20.80,0:02:24.91,Default,,0000,0000,0000,,After you've planned out the steps then\Ngo ahead and implement this in your app.
Dialogue: 0,0:02:24.91,0:02:27.56,Default,,0000,0000,0000,,Then, can you tell me what\Nmethod did you end up modifying?