All language subtitles for 033 Fixing the Constructor_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

The constructor's the first thing that runs as soon as you create a new object.

So it should be the one to update the fields of a newly created object.

In this lesson, you're going to fix your constructor.

Right now, we're calling the Senate to update the cars field, remove it.

Because when you create a new object, it's the constructor's job to update every field.

The dealership only has one field, so the constructor needs to receive one parameter.

An array of car objects and instead of a fixed length of three, the field is going to share the same

length as the parameter that gets passed in.

All right, so back in Maine, you need to pass in one argument that wage Albino's to call the constructor

with one parameter.

And the argument we're going to pass on is the cars are Ray.

And before testing the code, I'm going to add two more cars to the array being Pastan.

It's going to be a Honda.

Worth 7000 made in 2019.

A color of orange, and it's going to come with the standard tires and filter.

The last car is going to be a Mercedes worth twelve thousand.

Made in 2015, color of black.

And it's going to come with tires, filters, and that's put in a transmission.

All right.

And feel free to add as many car objects as you'd like, but I'm going to go ahead and print the dealership

object.

All right, there are five spots in the cars field and all of them are empty.

This makes sense because so far we're only set the length of the Crisfield, we still have an updated

every element, so every element along the array is going to be no.

OK, so the next step is to update every element in the cars filled with an object from the car's parameter.

So create a fault that runs through the length of the car's perimeter.

We can use the fawry shortcut and it creates a far loop that runs through the length of the nearest

array.

And now the cars field and cars parameter share the same length.

So using this for a loop, it can index every element in the car's field.

And at this point, careful not to fall into the reference trap.

Said every element in the cars field equal to a new car object.

In each new car, object is going to copy its values from a source and this source is going to be the

object that we're indexing from the car's parameter.

And that's it, you're ready to run your code.

And that's perfect.

There are five spots in the cars field and the constructor sets every element in the cars field equal

to an object from the car's parameter.

Why not use a raise a copy of.

You should not use a raised copy of for an array of objects.

A radar copy of Shallow Copy is the reference from every element.

So elements from both arrays are going to share a reference to the same object.

In other words, this would be the same thing as writing this.

Which means would be falling into a trap to.

Instead, use a loop that deep copies the object from every element.

So be careful, a, that copy of is going to shallow copy the reference of every element.

However, the loop deep copies the object from every element.

In this lesson, you fix the dealership constructor.

At first we were using the center to update the newly created dealership object, but when you create

a new object, it's the constructors job to run and update your fields.

In this case, the constructor sets every element in the car's field equal to an object from the car's

parameter.

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