Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
The solution is going to cover part three.
The second test case tells us that if a movie is removed after being sold, so write a unit test named
sell movie test.
And the movie we're going to sell is The Shawshank Redemption.
So ideally, calling cell should remove this object from the array list.
All right, and now we'll need to make an assertion.
Assert false, and this test will pass a Astorga that contains The Shawshank Redemption returns false.
And now inside Staudt Java, we can write code to make the test fail.
Public Void Cell Movie.
And the unit test implies that we need to pass a string into our method.
And for now, we'll do nothing, I want my test to fail.
And it does good now we need to write code to make the test pass.
The simplest code I can think of is to just create a loop that runs through the size of the array list.
And if the name of the movie object at the index.
Matches the name being Pastan.
Then we'll remove the movie and index I.
Let's run the test.
And it passes.
Here, it removes the movie and our assertion passes because the story doesn't contain it anymore.
OK, here comes the most important question can this be a refactored, can it be made simpler?
And the answer to that is absolutely loop's are really messy.
And since Java eight aerialists and call a remove F method.
They stop movies that remove if.
The remove, if once a predicate, a predicate is something that is true or false.
So that means our lambda expression is going to receive every element as a parameter.
Remember that every lambda expression has an arrow that points to a piece of code.
Where we need to return a boolean and we're going to return a boolean that checks, if the string of
the element we're running through is equal to the name parameter.
And as you can see, using a functional approach is more elegant than using loops.
And as we refactor, we always have to run the unit test to make sure that the new could be added does
not have any bugs and perfect the test passes.
Now, once again, can we refactor?
That's a question you have to keep asking yourself until you're absolutely certain that your code is
as simple as it's going to get in this case.
Yes, if the code is only one line, then you can remove the curly brackets as well as the return keyword.
And Jeff is going to know you intend on returning a boolean.
That's kind of cool if you ask me.
OK, I'll run the unit test.
And beautiful, the unit test passes, so I know that my code is working as intended now.
Once again, can we refactor?
Nope, we can move on to the next unit test.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.