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
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

Original subtitles

In the last section, we finished up the constructor on the deck class.

Now I'm going to assume that everything worked correctly, but in reality, I don't really know.

It would be really great if there is some way that we could kind of inspect this card's property right

here on the deck that we created inside of our main function.

For example, maybe if we could print out that entire list of cards to the terminal or the console over

here, we could then verify that the correct number and type of card is being added to the cards list

right here.

So let's try that out.

Let's try using that print function that we looked at previously to print out the deck that gets created

right here.

And maybe we'll be able to figure out what cards actually got inserted into this card list.

So to use that print function, I'm going to assign the deck we created right here to a deck variable.

I then called a print function and I'll pass the deck in like so.

Then I'll click run on the top, right, and we'll see what happens.

OK, so kind of underwhelming.

I got an output right here of instance of DEC.

So what really happens when we pass a variable to the print function?

It's kind of hoping we would see all the information that is contained within the stack, but instead

we got this very default, little bit of information.

So let's take a look at a diagram that's going to help us understand what the print function is really

doing for us.

OK, so here's what's happening, you and I are calling the print function and then we're passing in

on here, I put value technically we are passing in a variable or a reference, but I think you get

the idea here.

So what the print function does is it looks at that value and it says, hey, do you have a two string

method?

If that value has a two string method defined on it, it will be executed and then the result of that

method will be printed out to the console.

So if we want to customize how any value gets printed out, we can define that two string method and

we can customize what it returns to change what actually gets printed out.

Now, the two string function right here that I've listed out, this is a very special function name.

So when the print function is used and we Parzania value, the print function is going to look specifically

for a function called exactly to string.

So if we want to customize the print function, we have to define to string on our class.

So let's try this out and see what happens.

So I'm going to go back over to my code.

Here's my deck class.

So I want to customize how this thing prints itself out.

And I can do so by defining the two string method on it.

So I'm going to go down below my constructor, but still inside of the class body and I'll define the

two string function on here.

Now, just to make sure that this works the way we expect, I'm going to first try returning a very

silly string, I'll say something like this is a deck like so.

So now that we've defined this two string function print up here is going to call to string, any time

we pass in an instance of a deck, we're going to return the string right here.

And the print function is going to use the string as the representation of our deck.

So let's now try running this code again and seeing what happens.

OK, so now we see this is a deck as opposed to the previous instance of deck that we had before.

OK, so that definitely works to customize our print statement, but we're still not really able to

view the data that exists inside of our list of cards right here.

So let's take a quick pause.

We'll come back in the next section and we're going to continue working on this two string function.

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