All language subtitles for 6. Introduction & Requirements for the Coffee Machine Project

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese Download
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 0 1 00:00:00,360 --> 00:00:02,850 Now you should have PyCharm up and running, 1 2 00:00:03,030 --> 00:00:05,940 and we're finally ready to tackle today's project, 2 3 00:00:06,240 --> 00:00:10,110 which we're going to write in PyCharm. You've just been hired. 3 4 00:00:10,200 --> 00:00:14,250 Congratulations, but first there's the matter of coffee. 4 5 00:00:14,790 --> 00:00:18,750 We all know that programmers can't work unless they're loaded up on coffee. 5 6 00:00:19,260 --> 00:00:24,180 So your company has asked you to create the code for a coffee machine. 6 7 00:00:25,050 --> 00:00:29,310 Now you, very cleverly, go online and look at the other coffee machines. 7 8 00:00:29,580 --> 00:00:34,380 And you notice that it only costs $230 to buy a coffee machine, 8 9 00:00:34,860 --> 00:00:38,310 but you're not going to cheat. You're going to create everything from scratch. 9 10 00:00:38,910 --> 00:00:42,960 And luckily we don't actually have to build the hardware because we're programmers, 10 11 00:00:42,990 --> 00:00:43,740 right? 11 12 00:00:43,740 --> 00:00:48,740 But we're going to use this real-life coffee machine as the inspiration for our 12 13 00:00:49,170 --> 00:00:53,670 virtual coffee machine, noting the features and the capabilities. 13 14 00:00:54,330 --> 00:00:58,770 So what does it say? I found some wonderful graphics on here 14 15 00:00:59,130 --> 00:01:02,130 which tells me that they're three hot flavors 15 16 00:01:02,640 --> 00:01:07,170 which I'm guessing are these three buttons, it's coins operate 16 17 00:01:07,830 --> 00:01:12,720 which I think they mean it's coin operated, and there's not much else that it can 17 18 00:01:12,720 --> 00:01:13,530 do. 18 19 00:01:13,530 --> 00:01:18,510 Let's take this example and we're going to make a digital version of it. 19 20 00:01:18,510 --> 00:01:20,880 We're going to create our own coffee machine. 20 21 00:01:21,330 --> 00:01:25,830 And the first step we need to replicate is the ability to make three hot 21 22 00:01:25,830 --> 00:01:30,210 flavors. So the flavors we're going to make are 1. espresso, 22 23 00:01:30,420 --> 00:01:33,750 2. latte, and 3. cappuccino. Here 23 24 00:01:33,750 --> 00:01:36,870 are the recipes for these three types of drinks. 24 25 00:01:37,410 --> 00:01:40,140 Each of them requires a different quantity of water, 25 26 00:01:40,260 --> 00:01:43,470 a different quantity of coffee and a different quantity of milk. 26 27 00:01:43,920 --> 00:01:46,770 And they also each half a different price. 27 28 00:01:47,520 --> 00:01:51,360 We're going to be modeling all this data in our coffee machine program as well. 28 29 00:01:52,430 --> 00:01:55,040 But luckily for you in the starting code, 29 30 00:01:55,100 --> 00:01:58,250 I've already included all of this data inside a dictionary. 30 31 00:01:58,550 --> 00:02:00,170 So you don't have to remember this, 31 32 00:02:00,470 --> 00:02:03,530 although it might help if you're at home and you decided that you really wanted 32 33 00:02:03,530 --> 00:02:07,520 a latte instead of your usual black coffee. Now, in addition, 33 34 00:02:07,520 --> 00:02:10,820 the coffee machine has some resources that it has to manage. 34 35 00:02:11,180 --> 00:02:14,390 So it starts out with 300ml of water in the tank, 35 36 00:02:14,630 --> 00:02:18,050 200ml of milk and 100 grams of coffee. 36 37 00:02:18,530 --> 00:02:22,970 The second feature of our coffee machine is that it's coin operated. 37 38 00:02:23,450 --> 00:02:28,450 So we're going to be using American coins and they have four types of coins: 38 39 00:02:29,060 --> 00:02:31,760 the penny, the nickel, the dime, and the quarter. 39 40 00:02:32,330 --> 00:02:34,520 They used to also have the dollar as a coin 40 41 00:02:34,910 --> 00:02:38,000 but a few years ago they stopped minting that. So we're not going to count it 41 42 00:02:38,120 --> 00:02:40,370 and it probably means one less if statement for us. 42 43 00:02:40,880 --> 00:02:45,680 Notice what each of these coins are worth. The penny is worth a cent, 43 44 00:02:46,040 --> 00:02:49,010 the nickel worth 5 cents and the dime 10 cents, 44 45 00:02:49,040 --> 00:02:51,200 and the quarter is a quarter of a dollar. 45 46 00:02:51,650 --> 00:02:56,650 These represented in decimal values would look something like this. 46 47 00:02:57,920 --> 00:03:02,620 Now here's the important part. Let's think about what our program requirements are 47 48 00:03:02,650 --> 00:03:05,080 if we break it down one. 48 49 00:03:05,230 --> 00:03:08,050 1. We need our coffee machine to be able to print a report. 49 50 00:03:08,440 --> 00:03:11,680 It needs to be able to tell us what resources it has left, 50 51 00:03:11,710 --> 00:03:14,470 how much water has left, how much milk, et cetera. 51 52 00:03:14,980 --> 00:03:18,430 If you head over to the completed version of the coffee machine, 52 53 00:03:18,790 --> 00:03:21,190 the link is in the course resources, 53 54 00:03:21,610 --> 00:03:25,780 and you can go ahead and try out the final version of the coffee machine. 54 55 00:03:26,500 --> 00:03:31,500 So let's say that we wanted a report on all the resources that the machine has. 55 56 00:03:31,990 --> 00:03:36,970 All we have to do is type report, and we can see all the resources we have. 56 57 00:03:37,600 --> 00:03:40,030 Now, in addition to being able to print a report, 57 58 00:03:40,420 --> 00:03:45,400 we also want to be able to check that the resources are sufficient when the user 58 59 00:03:45,400 --> 00:03:50,380 orders a drink. Now let's say that the user decided to order a latte. 59 60 00:03:50,950 --> 00:03:55,950 It asks me to insert some coins and then it gives me the change and it gives me 60 61 00:03:56,530 --> 00:03:59,650 the latte. But now if I check the report, 61 62 00:04:00,010 --> 00:04:03,520 I can see that I've only got a hundred mils of water left. 62 63 00:04:03,910 --> 00:04:08,470 And I know from the previous slide that a latte and a cappuccino is going to 63 64 00:04:08,470 --> 00:04:12,370 need more than that amount of water. So let's see what happens 64 65 00:04:12,400 --> 00:04:16,510 if I go ahead and order a cappuccino. It says, sorry, 65 66 00:04:16,510 --> 00:04:17,800 there's not enough water. 66 67 00:04:18,280 --> 00:04:23,280 So our program is able to look through all the resources that the machine has, 67 68 00:04:24,340 --> 00:04:29,340 checks it against the recipe of the drink that we're trying to make, and tells the 68 69 00:04:29,890 --> 00:04:34,270 user if there is insufficient water or if there's insufficient milk, 69 70 00:04:34,630 --> 00:04:37,390 and as long as one of the resources is insufficient, 70 71 00:04:37,630 --> 00:04:42,580 then it can't make the drink and it gives the feedback to the user. Now, 71 72 00:04:42,610 --> 00:04:43,720 as you saw before, 72 73 00:04:44,140 --> 00:04:48,550 our program also needs to be able to process coins because our machine is coin 73 74 00:04:48,580 --> 00:04:49,413 operated. 74 75 00:04:50,170 --> 00:04:54,610 So no fancy contactless payments or pay with your Apple watch, none of that. 75 76 00:04:54,700 --> 00:04:57,910 We've only got coins. When we order something, 76 77 00:04:58,690 --> 00:05:01,090 it should ask us to insert coins. 77 78 00:05:01,630 --> 00:05:04,810 And it's going to ask for the quantity of each type of coin. 78 79 00:05:05,260 --> 00:05:09,490 So let's say that I insert one of each, then in this case, 79 80 00:05:09,580 --> 00:05:14,580 there's actually not enough money to cover my drink and it refunds the money and 80 81 00:05:14,740 --> 00:05:19,630 doesn't give me a drink. But on the other hand, if I do insert enough money, 81 82 00:05:20,410 --> 00:05:25,150 then it should be able to calculate how much money all of these coins are worth 82 83 00:05:25,570 --> 00:05:29,530 and then calculate the amount of change based on the cost of my drink. 83 84 00:05:30,010 --> 00:05:34,480 And then it should hand me my drink and tell me to enjoy. So, 84 85 00:05:34,510 --> 00:05:37,720 in addition to being able to process the four types of coins, 85 86 00:05:37,750 --> 00:05:41,560 calculating the actual monetary value based on the number of points, 86 87 00:05:41,860 --> 00:05:44,500 it should also check that the transaction is successful. 87 88 00:05:44,530 --> 00:05:49,530 That the user didn't try to hoodwink us by not giving enough coins and asking 88 89 00:05:49,540 --> 00:05:53,080 for a drink. So if they haven't inserted enough coins, 89 90 00:05:53,350 --> 00:05:55,780 then we're just going to refund them and tell them, sorry 90 91 00:05:55,780 --> 00:05:58,970 that's not enough money, and not give them their drink. 91 92 00:05:59,390 --> 00:06:02,150 But if the transaction was successful, 92 93 00:06:02,450 --> 00:06:07,040 then we're going to make the coffee. And in the process of making the coffee, 93 94 00:06:07,280 --> 00:06:09,560 we're going to have to deduct the resources. 94 95 00:06:10,070 --> 00:06:12,680 Notice how every time we make a drink, 95 96 00:06:12,710 --> 00:06:16,670 say in this time we made a latte and previous to the latte, 96 97 00:06:16,700 --> 00:06:20,300 we have 300 mills of milk. But after the latte, 97 98 00:06:20,330 --> 00:06:24,110 when we asked for the report, you can see that the water has been reduced, 98 99 00:06:24,110 --> 00:06:25,190 the milk has been reduced, 99 100 00:06:25,220 --> 00:06:28,840 the coffee has been reduced and the money has been put into the coffer. 100 101 00:06:29,690 --> 00:06:32,150 This program, even though it seems simple, 101 102 00:06:32,180 --> 00:06:35,240 just a simple digital version of a coffee machine, 102 103 00:06:35,720 --> 00:06:38,420 it actually has quite a few requirements. 103 104 00:06:38,960 --> 00:06:43,960 So I recommend that you look at the screen and try to see how each of the 104 105 00:06:44,510 --> 00:06:49,510 requirements work by having a play around with the final version of the code. Now 105 106 00:06:51,080 --> 00:06:56,080 I've created a detailed program specification for you as a PDF file 106 107 00:06:56,690 --> 00:06:59,510 which you can download in the course resources. 107 108 00:06:59,930 --> 00:07:04,520 And this goes into a lot more details on each of those points. For example, 108 109 00:07:04,520 --> 00:07:08,360 what should the prompt print in the beginning of the program, 109 110 00:07:08,810 --> 00:07:12,020 and then how to turn the machine off, 110 111 00:07:12,410 --> 00:07:17,410 how to print the reports and how each of those points should work in detail. 111 112 00:07:19,010 --> 00:07:23,780 Go ahead and download this and make sure you read each of the sections and test 112 113 00:07:23,780 --> 00:07:27,620 it out in the final working version of the project. 113 114 00:07:28,730 --> 00:07:29,810 Once you're ready, 114 115 00:07:29,870 --> 00:07:34,760 you can go ahead and head over to the starting version of the code. And again, 115 116 00:07:34,760 --> 00:07:36,560 I'm sharing this using Repl.it, 116 117 00:07:36,830 --> 00:07:39,560 but I want you to copy everything that's in here, 117 118 00:07:39,650 --> 00:07:42,290 there's only one file the main.py file, 118 119 00:07:43,010 --> 00:07:48,010 and I want you to create a new project using PyCharm and call it coffee 119 120 00:07:48,410 --> 00:07:48,880 machine, 120 121 00:07:48,880 --> 00:07:49,713 Right? 121 122 00:07:51,940 --> 00:07:56,920 And then create a new file inside your project called main.py, 122 123 00:07:58,750 --> 00:08:03,550 and then paste all of the starting code into your main.py. 123 124 00:08:04,060 --> 00:08:08,260 And now you are going to code inside this file. And once you're ready, 124 125 00:08:08,290 --> 00:08:13,210 you're going to click run and you'll be able to run this main.py down here 125 126 00:08:13,510 --> 00:08:16,750 and this will act as your console. Now, 126 127 00:08:16,750 --> 00:08:19,750 one really handy feature of 127 128 00:08:19,750 --> 00:08:23,020 PyCharm is something called to-do tracking. 128 129 00:08:23,830 --> 00:08:28,780 Whereas previously in Repl.it I've been creating to-dos and you've been able to 129 130 00:08:28,780 --> 00:08:33,280 view them. But if I have lots of to-dos in different places, 130 131 00:08:33,580 --> 00:08:35,410 you can't actually see all of them at once. 131 132 00:08:35,410 --> 00:08:37,420 You have to scroll through the file looking for them. 132 133 00:08:37,960 --> 00:08:39,850 But in a professional tool, 133 134 00:08:40,120 --> 00:08:45,070 we actually have something called to-do tracking and its a tab that's down here. 134 135 00:08:45,940 --> 00:08:49,210 So if I go ahead and take some of these program requirements, 135 136 00:08:49,510 --> 00:08:52,540 I can put them in as to-dos. To create a 136 137 00:08:52,540 --> 00:08:57,540 to-do you have to follow the syntax. First is a pound sign 137 138 00:08:58,320 --> 00:09:03,320 and then we write TODO in all caps, and notice how that's just changed color just 138 139 00:09:03,570 --> 00:09:06,690 now, and now you can see in the todo tab, 139 140 00:09:06,720 --> 00:09:08,640 it's found one todo item. 140 141 00:09:09,420 --> 00:09:12,930 Now we can write todo number one 141 142 00:09:13,530 --> 00:09:17,970 and this is to print a report of all the coffee machine resources. 142 143 00:09:19,080 --> 00:09:23,010 Now let's say that I created a todo somewhere else, right? 143 144 00:09:23,040 --> 00:09:24,630 Like all the way up here, 144 145 00:09:25,770 --> 00:09:30,770 check that the resources are sufficient to make the drink order. And notice how 145 146 00:09:31,620 --> 00:09:34,620 they're completely in different places in a different order. 146 147 00:09:34,920 --> 00:09:38,490 But every time I create one of these todos using this format, 147 148 00:09:38,520 --> 00:09:39,810 it will get picked up in the 148 149 00:09:39,810 --> 00:09:43,500 todo tab. And you can go ahead and see where they live. 149 150 00:09:43,860 --> 00:09:47,370 So it's found two items inside our main.py 150 151 00:09:47,850 --> 00:09:51,390 and you can see that this one is todo one, this one is todo two. 151 152 00:09:51,690 --> 00:09:52,770 And when you click on them, 152 153 00:09:52,860 --> 00:09:55,500 they'll take you to the correct places in your code. 153 154 00:09:56,460 --> 00:10:01,460 Use this to break down the problem into smaller problems that you can solve one 154 155 00:10:01,530 --> 00:10:02,310 by one, 155 156 00:10:02,310 --> 00:10:06,720 just as you've done before and try to see if you can complete this project. 156 157 00:10:07,500 --> 00:10:11,100 Just the word of warning: this project is quite ambitious. 157 158 00:10:11,400 --> 00:10:14,130 But you've now got professional tools to help you, 158 159 00:10:14,520 --> 00:10:17,850 and you've got a lot more skill under your belt. 159 160 00:10:18,390 --> 00:10:22,680 So give this problem at least an hour to work on it and make sure that you 160 161 00:10:22,680 --> 00:10:27,180 satisfy all the criteria that's set out in the program requirements 161 162 00:10:27,270 --> 00:10:32,270 and also that your program works exactly the same as the final version of the 162 163 00:10:33,690 --> 00:10:34,500 coffee machine. 16245

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.