All language subtitles for 010 Creating Classes_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 started talking about object oriented programming and d'arte in this section,

we're going to write out a little bit of code to get a better idea of how classes work in Darte later

on.

Throughout the course, we'll have a lot more deeper discussions about object oriented programming and

some of the theory behind it.

But for right now, let's just write a little bit more code.

So to get a better idea of how classes work, you and I are going to create a new class over inside

of D'Arte.

This class is going to model how a person behaves or kind of model a person just by on their own, I

suppose.

Are person class is going to have one piece of data or one field associated with it, which we refer

to as the person's first name.

This first named property or field will have a value of type string, and so just like we had before

in our last application, we were returning a string of Stephen right here.

Essentially, this string is now going to exist on an instance of the person class.

After creating that field will then associate a single method with the person class as well.

We'll call that method print name.

This is going to be a function that takes the person's first name property and then prints it out to

the terminal.

So in total, this is going to be a class that does very similar behavior to the current program that

we have over here.

OK, so let's get started.

It's about back over inside of Arpad, I'm going to highlight all the code that we had before and I'm

going to delete it.

Well, then get started by implementing our person class inside of here.

Remember, every programmer we create has to have a main function.

So at some point in time, we're gonna have to recreate that main function again.

But we'll take care of the class first and then we'll do the main function later.

So to create the person class, I will write out the keyword class and then the name of the class,

which is person notice on using an uppercase name here.

So any time we create a class, we always use an uppercase leading character.

Then inside of the curly braces, we have our class body at the very top or the first couple of lines

inside the class body.

We have the opportunity to declare all the different fields that should be associated with this class.

You and I want to have a single field of type string and the field should have a name of first name,

so to do so or to actually implement that will right out string first name and then a comma or a semicolon

like so.

So this declares a new field of type string called first name on the person class.

Next will add on a method called print name, and any time we call this, we want to log out the value

of this person's name.

Let's go back over inside of D'Arte pad, I can add on a method by writing out the name of the method

first, which is going to be print name, then instead of parentheses and then a set of curly braces.

So this looks like identical syntax to the functions that we were looking at earlier in our last program

that we put together.

Then inside of these curly braces, we can add some code to be executed any time this method runs.

So in this case, we want to printout this person's first name property.

So to do so, I'll write out simply print first name.

Now, one thing you'll notice here is that to reference the first name property that belongs to this

person, we simply wrote out first name.

This is a little bit different than in many other languages, particularly Java or JavaScript, where

you might write out first this DOT and then the actual property name.

This right here, adding into this dot is completely valid syntax inside of dirt, so if you want to

write out long form this dot and then the property name that you're trying to refer to, you absolutely

can.

But it's not required by darte.

If you just write out the property name that you're trying to reference and leave off the this dot dart

is still going to figure out what you're trying to do and kind of fill in the blanks from there.

OK, so this in total has defined our first person class.

Remember, this is just kind of a blueprint of sorts and we can't actually use this just yet for making

use of the person class.

We have to use it to create an object or an instance of that class.

And then once we have that instance, we can actually start to assign or set some data inside the instance.

So let's come back in the next section and we'll take care of that in the next video.

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