All language subtitles for 009 Customizing Print Statements_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian Download
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
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:03,870 In the last section, we finished up the constructor on the deck class. 2 00:00:04,350 --> 00:00:08,940 Now I'm going to assume that everything worked correctly, but in reality, I don't really know. 3 00:00:09,400 --> 00:00:14,100 It would be really great if there is some way that we could kind of inspect this card's property right 4 00:00:14,100 --> 00:00:16,910 here on the deck that we created inside of our main function. 5 00:00:17,580 --> 00:00:22,800 For example, maybe if we could print out that entire list of cards to the terminal or the console over 6 00:00:22,800 --> 00:00:28,560 here, we could then verify that the correct number and type of card is being added to the cards list 7 00:00:28,560 --> 00:00:29,060 right here. 8 00:00:29,730 --> 00:00:31,050 So let's try that out. 9 00:00:31,080 --> 00:00:36,180 Let's try using that print function that we looked at previously to print out the deck that gets created 10 00:00:36,180 --> 00:00:36,660 right here. 11 00:00:36,900 --> 00:00:41,490 And maybe we'll be able to figure out what cards actually got inserted into this card list. 12 00:00:42,180 --> 00:00:47,490 So to use that print function, I'm going to assign the deck we created right here to a deck variable. 13 00:00:48,360 --> 00:00:51,660 I then called a print function and I'll pass the deck in like so. 14 00:00:53,000 --> 00:00:56,180 Then I'll click run on the top, right, and we'll see what happens. 15 00:00:56,750 --> 00:00:58,460 OK, so kind of underwhelming. 16 00:00:58,880 --> 00:01:01,610 I got an output right here of instance of DEC. 17 00:01:02,270 --> 00:01:06,260 So what really happens when we pass a variable to the print function? 18 00:01:06,770 --> 00:01:11,480 It's kind of hoping we would see all the information that is contained within the stack, but instead 19 00:01:11,480 --> 00:01:13,880 we got this very default, little bit of information. 20 00:01:14,240 --> 00:01:18,590 So let's take a look at a diagram that's going to help us understand what the print function is really 21 00:01:18,590 --> 00:01:19,490 doing for us. 22 00:01:20,850 --> 00:01:25,740 OK, so here's what's happening, you and I are calling the print function and then we're passing in 23 00:01:25,920 --> 00:01:31,230 on here, I put value technically we are passing in a variable or a reference, but I think you get 24 00:01:31,230 --> 00:01:31,960 the idea here. 25 00:01:32,430 --> 00:01:37,980 So what the print function does is it looks at that value and it says, hey, do you have a two string 26 00:01:37,980 --> 00:01:38,490 method? 27 00:01:39,530 --> 00:01:45,950 If that value has a two string method defined on it, it will be executed and then the result of that 28 00:01:45,950 --> 00:01:48,510 method will be printed out to the console. 29 00:01:49,070 --> 00:01:55,520 So if we want to customize how any value gets printed out, we can define that two string method and 30 00:01:55,520 --> 00:01:59,600 we can customize what it returns to change what actually gets printed out. 31 00:02:00,470 --> 00:02:05,170 Now, the two string function right here that I've listed out, this is a very special function name. 32 00:02:05,690 --> 00:02:11,270 So when the print function is used and we Parzania value, the print function is going to look specifically 33 00:02:11,270 --> 00:02:14,390 for a function called exactly to string. 34 00:02:15,710 --> 00:02:21,660 So if we want to customize the print function, we have to define to string on our class. 35 00:02:21,860 --> 00:02:23,540 So let's try this out and see what happens. 36 00:02:24,380 --> 00:02:26,000 So I'm going to go back over to my code. 37 00:02:26,720 --> 00:02:27,880 Here's my deck class. 38 00:02:27,890 --> 00:02:31,010 So I want to customize how this thing prints itself out. 39 00:02:31,010 --> 00:02:34,130 And I can do so by defining the two string method on it. 40 00:02:35,060 --> 00:02:40,880 So I'm going to go down below my constructor, but still inside of the class body and I'll define the 41 00:02:40,880 --> 00:02:42,200 two string function on here. 42 00:02:43,300 --> 00:02:47,530 Now, just to make sure that this works the way we expect, I'm going to first try returning a very 43 00:02:47,530 --> 00:02:51,550 silly string, I'll say something like this is a deck like so. 44 00:02:53,570 --> 00:02:59,780 So now that we've defined this two string function print up here is going to call to string, any time 45 00:02:59,780 --> 00:03:04,130 we pass in an instance of a deck, we're going to return the string right here. 46 00:03:04,310 --> 00:03:09,020 And the print function is going to use the string as the representation of our deck. 47 00:03:09,710 --> 00:03:12,440 So let's now try running this code again and seeing what happens. 48 00:03:13,580 --> 00:03:18,620 OK, so now we see this is a deck as opposed to the previous instance of deck that we had before. 49 00:03:19,370 --> 00:03:24,350 OK, so that definitely works to customize our print statement, but we're still not really able to 50 00:03:24,350 --> 00:03:28,010 view the data that exists inside of our list of cards right here. 51 00:03:28,490 --> 00:03:29,480 So let's take a quick pause. 52 00:03:29,480 --> 00:03:33,740 We'll come back in the next section and we're going to continue working on this two string function. 5402

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