All language subtitles for 014 Movie Store – Part 4 (Task 1)_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

The solution is going to cover part for.

We'll come back to the third test case, but the fourth one tells us to check if a movie is unavailable

after it's rented.

So I'll write a unit test named Rent a movie test.

And inside our rent out The Godfather.

And then our unit test is going to assert The Godfather isn't available after Rentoul assert false store,

get movie.

At index one is available.

OK, now inside, start our Java write code to make the test failed.

I'll define a function named Arunta movie.

It's a void and receives a string parameter name.

And for now, we'll do nothing.

Our test fails, that's fine, let's write code to make it pass.

Inside the movie, I'm going to create a loop that runs through the size of the array list.

And when it finds a name that matches the one being Pastan.

Then we'll set its availability to false.

If we were on our test now, it should work.

I can run the debugger.

Rent, movie updates, the availability to false and our assertion passes.

Now, can rent movies be simpler?

Absolutely.

Rent movies, doing way too much work, it's retrieving the index and it's setting the movie's availability

to false.

It should only be performing a single task.

So we'll create another method that's solely responsible for retrieving the movie index, a function

name is get movie index.

It returns an integer and receives a string parameter called name.

And inside this function, we're going to copy over the logic from rent a movie.

And if it doesn't find a movie, we still need to return and we'll use negative a thousand to indicate

that it couldn't find anything.

OK, and now we can all get moving index from rent a movie.

And this looks better, I like it when each function is only performing one task.

This is what I mean when I say Modula.

OK, if we rerun the test, it passes good, we don't have any bugs.

But we still have to ask the question, can we refactor?

And the answer is yes, loops are pretty messy.

And since Java eight, we can use something called an end stream.

What an end stream does is it goes through a pipeline of functions until it returns an integer that

represents an index.

First, you need to specify the range from which you're getting the index.

The range is going to start from zero until the size of the array list.

The next operation is filter.

Filter, expecta, lambda expression that returns a boolean, the lambda receives each index from zero

until the size of the array list.

We're going to call it I.

And for each index, we're going to return a boolean that checks if the name of the movie object at

the requested index.

Equals the parameter.

And Stream is going to filter the index for which this condition is true.

And now we need to return this index, so we'll use the terminal operation, find first, find first

is a terminal operation because it ends the pipeline by returning the first index for which this condition

is true.

And if fine first, does it find anything if all of the indexes return false?

Then we'll say or else.

Negative, a thousand.

And we'll return the result that comes out of this pipeline.

OK, as you can tell by now, I'm a pretty big fan of replacing Lupe's with a pipeline of functions

whenever I can.

And as always, as you refactor, run the unit test to make sure there aren't bugs and there aren't

any perfect.

So now we ask ourselves the same question, can it be a refactored and the answer is yes.

If your expression is only a single line, then you can remove the curly brackets as well as the return

keyword.

And Java is going to know you intend on returning the Boolean.

We run the unit test.

And beautiful.

Once again, can the code be refactored?

Nope, we're done.

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