All language subtitles for 007 Adding Elements to Lists_en

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 Download
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
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: 1 00:00:00,750 --> 00:00:05,640 We've now got our double nested for loops put together, so we're iterating over all of the suits and 2 00:00:05,640 --> 00:00:12,030 rings within this list now inside of this body right here, we need to create a new instance of a card 3 00:00:12,540 --> 00:00:15,900 and then put that card into our big list of cards inside the deck. 4 00:00:16,970 --> 00:00:21,260 Now, to create the new card itself, it's going to be pretty straightforward, so to make the card 5 00:00:21,260 --> 00:00:27,020 we can save our card is a new card, very similar to how we've called other constructors or created 6 00:00:27,020 --> 00:00:29,270 new instances of classes before. 7 00:00:30,200 --> 00:00:34,580 But there's one thing I want to mention here, when we create our new card right here, we probably 8 00:00:34,580 --> 00:00:40,130 want to pass in the suit and the rank that we're currently iterating over so that this newly generated 9 00:00:40,130 --> 00:00:44,020 card right here knows what suit and rank it's supposed to represent. 10 00:00:44,840 --> 00:00:49,840 But if you look down at our card class, we have not yet set up a constructor function on this thing. 11 00:00:50,330 --> 00:00:53,210 So if we called new card right here, well, this would definitely work. 12 00:00:53,360 --> 00:00:58,910 But we do not yet have the ability to pass in the given rank and suit of the card. 13 00:00:59,510 --> 00:01:03,400 As a matter of fact, when I add that code in, I'm probably going to end up seeing an error. 14 00:01:03,950 --> 00:01:04,720 Here it is right here. 15 00:01:04,730 --> 00:01:08,120 So too many positional arguments, zero expected, but two found. 16 00:01:08,540 --> 00:01:13,520 So this is complaining and saying, hey, you're passing in the rank in the suit, but the card is not 17 00:01:13,520 --> 00:01:15,980 set up to expect those arguments whatsoever. 18 00:01:16,730 --> 00:01:20,060 So down inside the card, we're going to add a constructor function here as well. 19 00:01:20,450 --> 00:01:25,610 And we're going to make sure that if we pass in the rank and the suit, we take them and initialize 20 00:01:25,610 --> 00:01:28,340 the appropriate properties on our card instance. 21 00:01:29,000 --> 00:01:32,780 Now, this is another thing we did previously just a moment ago with our person class. 22 00:01:33,020 --> 00:01:35,270 So we're going to write out some very similar looking code. 23 00:01:36,160 --> 00:01:39,460 So inside of my card class, I'm going to add on a constructor function. 24 00:01:41,240 --> 00:01:46,550 And then remember the shorthand form that we can use to take some arguments in automatically assign 25 00:01:46,550 --> 00:01:49,010 them to some fields that belong to this class. 26 00:01:50,010 --> 00:01:55,860 So notice that the rink is the first argument here, so I can take that first argument and automatically 27 00:01:55,860 --> 00:02:00,480 assign it to this rank property here by writing this rank. 28 00:02:01,580 --> 00:02:04,510 And then I'll repeat the same process for the suit as well. 29 00:02:05,090 --> 00:02:06,740 So let's say this suit. 30 00:02:07,990 --> 00:02:13,420 So now, whenever we call new card and passing the rank in the suit, those two properties will be automatically 31 00:02:13,420 --> 00:02:16,420 assigned to the relevant fields on the card instant's. 32 00:02:18,260 --> 00:02:23,120 So now we've got the appropriate card created here, and this code right here is going to run 52 times 33 00:02:23,120 --> 00:02:26,550 once for every combination of suit and rank. 34 00:02:26,600 --> 00:02:28,280 Well, for me, not 52, two times. 35 00:02:28,280 --> 00:02:29,320 But you get the idea. 36 00:02:30,410 --> 00:02:36,800 So now that we've created the card, we need to take that card and add it to our list of cards to add 37 00:02:36,800 --> 00:02:42,200 a new element to a list, we can reference the list itself, which is going to be in this case, simply 38 00:02:42,200 --> 00:02:42,820 cards. 39 00:02:43,370 --> 00:02:47,060 Remember, in part, we don't have to say this cards or anything like that. 40 00:02:47,060 --> 00:02:49,010 We optionally can, but we do not have to. 41 00:02:49,490 --> 00:02:53,570 So I'll simply say cards and then to add a new element, I'll say add. 42 00:02:54,470 --> 00:02:57,980 And then I'll pass in the element that I want to add to that list like so. 43 00:02:59,240 --> 00:03:00,830 OK, so this is looking pretty good. 44 00:03:00,980 --> 00:03:04,940 I am going to tell you that there is a very subtle air inside this code right now. 45 00:03:05,330 --> 00:03:06,890 So there's a very small bug. 46 00:03:07,430 --> 00:03:12,640 Let's add in a new main function to this file so that we can test out this new debt class. 47 00:03:12,950 --> 00:03:18,320 And then when we run that code, we're going to see that air kind of a peer or the very subtle bug appear. 48 00:03:18,530 --> 00:03:21,080 And we'll take a quick pause and talk about what's going wrong. 49 00:03:21,830 --> 00:03:24,950 So let's add in the main function at the very top up here. 50 00:03:24,960 --> 00:03:26,180 I'll add in void main. 51 00:03:27,450 --> 00:03:32,190 And I'll just create a new deck by writing out new deck, and then we don't have to actually do anything 52 00:03:32,190 --> 00:03:34,620 with that, I just want to run the constructor function. 53 00:03:35,660 --> 00:03:36,830 OK, so I click on Ron. 54 00:03:38,200 --> 00:03:43,150 And then you're going to notice an error message on the top right up here, it says Dot ad is not a 55 00:03:43,150 --> 00:03:43,690 function. 56 00:03:44,000 --> 00:03:46,630 OK, so like I said, very subtle error in here. 57 00:03:46,910 --> 00:03:48,130 So let's take a quick pause. 58 00:03:48,130 --> 00:03:52,750 We'll come back to the next section and try to figure out exactly why we saw this error message. 59 00:03:53,020 --> 00:03:55,290 So quick break and I'll see you in just a minute. 6030

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