All language subtitles for 004 Part 2 (Solution) Tasks 1–4_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 Download
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

This solution is going to cover tasks one to four from part two, this part is exciting because we get

to revisit 2D arrays and nested loops and the vending machine is identified by the items that it manages.

And it has one action dispensing an item.

And since the items are arranged in rows right there, we know that the field needs to be a tutelary.

So add the items field to the machine class.

And as always, if your class has fields, you need to apply the big three steps, we need a constructor,

a getter and a setter.

The constructor is public, as always, shares the same name as the class.

And it's going to receive as many parameters as there are fields, so one, a 2D array of items whose

values we're going to copy into the items field.

So first, we need to set the field equal to a new 2D array.

Remember that the first bracket is the number of rose, the items field is going to have the same number

of rose as the items parameter.

And the second bracket refers to the number of elements in each row, you can pick any row from the

items parameter.

It doesn't matter which row, they all have the same number of elements.

So I'm going to zero zero.

And we'll get the length of Rosero.

OK, now we need to run through every object in the items parameter we can use for eye to autocomplete,

the outer loop.

And this loop is going to run through every row and the items parameter, where is the Arrow Index and

once again we can use for it to complete the inner loop.

But be careful as the outer loop runs through every row eye, the inner loop needs to run through every

element in that row.

I.

Inside the inner loop, the euro index is going to be fixed to a row while the Innaloo counterplay j

index is a specific element in that euro.

And we're going to set every element I and spot J equal to a new items copy of every element in the

items parameter at eye and spot J.

And that's really the constructor is going to update every element in the items field with an object

from the items parameter.

Next, we want to get her.

I receives two parameters, the row.

And the spot within that row.

And this letter is going to return.

A new item copy of the object.

At the request that spot inside the row, that was Pastan.

All right, that's all.

Next, we want to add a Seder that receives three parameters.

An item object that you're going to use to update one of your elements, the row and spot of the object

that you want to update.

All right, then, we're going to end next the object at the requested spot inside the row.

And set it equal to a new copy of the object being passed in.

And not so I think we're ready to test our code.

Inside men, Alan, comment, the items are Ray.

Then I'll create a new object of the machine class.

And I'll pass in the array to the constructor.

And let's say I want to get this object.

I'm going to use the GETER to get the object I wrote to.

And one of the items field.

Then I'm going to print that object directly.

Run the code.

And perfect, the constructor works because it clearly populated the items field with every item object

and the getter works as well.

Last thing I want to do is test the setar, so before putting the object at row and spot one, I'm going

to change the price of that same object.

So I'll store this in a variable.

Change its price, so we'll call the set price.

Then I'm going to call machine that said item with the new item we just updated.

Row two and spot one in.

All right, let's run the code.

I'm anticipating that the updated items would have a price of two ninety nine.

And this output, I can confirm that the constructor getter and setter are all working as they should.

I hope you were able to follow along if you were having trouble with the concept of two.

I encourage you to revisit the array section in Module one.

We cover 2D arrays and nested loops in a lot of detail.

But if you're comfortable with what we did so far, then we're going to implement tasks five to seven

in the next video.

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