All language subtitles for 007 Parent Class_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
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
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

Child classes can inherit from a parent class.

In this lesson, two classes will inherit from a parent class.

First, open up the folder for this lesson by following this path in your course resources.

And now from the requirements, we can identify what seems to be three objects, store shirt and pants.

We're not going to criticize or object and we're not going to be writing any unit tests just to keep

the focus on inheritance.

OK, let's get right to it, so first we have to create a shirt class.

The requirements tell us that shirt has Fairfield's private string size.

Private double price.

Private string color.

And private string brend.

And naturally, we would create a constructor that receives four parameters.

OK, now you want to set every field in the object that's being created equal to a parameter this size,

equal size, the stock price equals price, the stock color.

Equals color.

This thought brand equals brand.

For now, don't do anything else for this class.

We'll move on and create a pince class.

Public class pant's.

And instead of a size field, the pants class defines a waste field.

The remaining fields are identical to the ones for shirt, so could we just copy them over?

You know how I feel about copying and pasting code.

You should never do it before.

Now I'll entertain it.

Let's go through with it.

And I guess we could also copy and paste the constructor.

Change shirt, the pants, and instead of shrink size put into waist.

Now, on that very same note, never, ever copy and paste code.

If you copy and paste code, that means you're doing something wrong.

What we did here is really, really bad.

If you decide to copy and paste now, then you would end up copying and pasting together as the setters.

Let me generate them really quick.

And then, heck, why not copy and paste those as well?

OK, now I hope you see my point, never copy and paste code, it's really, really bad practice.

This is why inheritance is so important.

Inheritance makes code reuseable shirt and pants need to inherit from a parent class.

Shirt and pants share similar fields.

Instead of defining the same fields in each class, they should inherit common fields from a parent

class.

In other words, shirt and pants are children of the product class inside models create a product class

product Java.

The product class is going to define fields that shirt and pants have in common.

It's a private double price.

Privates Tranquila.

Private string brand.

And now you can remove these fields from Pentz.

We'll get errors here, so remove the field updates inside the constructor and delete all the letters

and setters.

We'll do the same thing for shirt.

Remove the field updates in the constructor.

As well as the getters and setters.

Now, a class that extends another class inherits from its.

Pants and shirt must extend the product class.

And that's really it now the pants class and shirt class are inheriting from their parent class product.

OK, now how can we make sure that pants and shirt are actually inheriting from the product class easy

inside main an object of the shirt class.

Percent a size of small.

A price of five ninety nine.

A color of blue.

And a brand of will say job over time.

Now, put a break point.

And run the debugger.

It creates a new object of the class, you can see the object includes the field inside the child.

Class size.

But wait a second, it also includes the fields that an inherited price color and bred.

Let's make sure Pence is inheriting from product create a new object of the pants class.

Passing a waste of 30 to a price of twenty four point ninety nine, a color of blue.

And a brand of, let's say, Javor Klein.

Run the debugger.

It creates a new object of the pants class.

You can see that the object includes the field inside the child class waste.

But wait, it also includes the fields that an inherited price, color and bread, that is inheritance.

All I want you to take away from this lesson is this when two classes share common fields, never defined

the same fields in each class.

Instead, each class should inherit common fields from a parent class.

Child classes can inherit from a parent class.

When two classes share common fields, never defined the same fields in each class.

Instead, they should inherit common fields from a parent class.

Shirt and pants shared similar fields, but instead of defining the same fields in each class, they

inherited common fields from a parent class.

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