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 two.
And the team constructor, through an illegal argument exception, if any of the fields are null or
any of the string values are blank.
Also, if housecalls null or if the keeper equals null or if the seeker equals null.
Then throw a new illegal argument exception.
Field values cannot be no.
Then say if a house is blank.
Or if keeper is blank.
Or if speaker is blank.
Throw a new illegal argument, exception.
Field values cannot be blank.
And finally, if the length of chasers is not equal to three.
Well, throw a new illegal argument exception.
Must have three chasers.
We need to throw another exception if the Chaser's Array contains an illegal element, the logic to
implement that without using loops is I consider meaningful code that we should write using test driven
development.
Accordingly, the first test case is to test if Chaser's Array has illegal elements.
So we'll write a unit test named has null test.
Inside the test, I'll define an era where the first element is known.
And the other two are filled.
And then you can use a search through.
To check if team has no.
Returns true for this array.
OK, now inside Team Java, we can write code to make the test fail.
I'll create a method that returns a boolean.
Named has no.
And for now, I'll just return false.
And I'm going to make this method static because I don't want to have to create an object just to call
a method that doesn't interact with any fields'.
I want to be able to call this method directly from the class.
So by making it static, we specify that this function belongs to the class.
Anyways, the test fails, OK, now we need to write code to make the test pass.
Inside the function, use a for loop that runs through the length of the array.
And we'll return true if any element is no.
Otherwise, return false.
Run the test.
And it passes.
But can this code be any simpler, can it be a refactored and the answer is a resounding yes, loops
are messy, and if you're able to use a stream pipeline, which is normally the case when you're dealing
with arrays or array lists, then use a stream.
In this case, we can use the arrays, utility class.
To call the method stream.
And remember that history is a sequence of elements that we can run through a pipeline of operations
and we're just going to apply the terminal operation any much, any match is going to compare every
element in the array against a predicates.
The lambda expression receives every element.
And any match is going to check if any element is equal to No.
And if any of them are not, any match is going to return, true, so we'll just return the result of
this pipeline.
Run the tests now and Perfect's.
One of the elements is known and the sequence of elements enters the pipeline as a stream and any match
returns true because one of the elements matches the predicates.
Can this could be any simpler than that?
No, we can move on.
OK, we also need to create a test that checks if any of the elements are black.
So once again, create a test that fails.
Public void has blank test.
And create an array where the first element is blank.
And then we can use a true.
To check if team has blank returns, true.
An outside team, Java, we can write code to make the test fail, I'll get a static method that returns
a boolean named has blank receives an array.
And for now, I'll just return false.
And the test fails.
OK, now we need to write some code to make it pass.
I'll skip the explanation, use the same pipeline as before.
But this one is going to return true if any of the elements happen to be blank.
Run the test.
And it passes.
There is no need to refactor this code.
We can move on.
OK, now in the constructor, I can say if The Chaser's Parameter has no.
Or has blank.
Then they need to throw an illegal argument exception.
Legal elements.
OK, now we can apply the same quality control inside the setas.
If House is Neller blank.
Through a new legal argument exception.
We'll copy this over here, change some things up.
One more time for speaker.
And that's it, and for chasers will check if chasers that length is not equal to three.
Or has no chaser's.
Or Chaser's has blank.
Then we'll throw a new illegal argument, exception, a legal chaser, arguments.
OK, now, before we wrap up, we seem to be using this code a lot.
So how about we create a function called Sheck Field?
That checks if some field is another blank.
So if the field being passed in is No.
Or blank, then we're going to throw a new illegal argument, exception.
That field cannot be null or blank.
And now wherever you can invoke this function.
You unit tested two methods, each method is modular and free of bugs and to make sure you can run every
test.
And seeing these beautiful green check marks is a good reminder that our code is working as it should.
You also added checkpoints to the team class, each checkpoint forbids the caller from misusing the
methods or constructor.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.