I every man.
So in this story I'm going to go ahead and I'm going to go inside this class country datasource class
and inside this file and inside the curly braces of this class I'm going to create a new method called
match with minimum level confidence of use or words.
So let's create that.
Here it is going to be a public method.
And if you're going to specify the return type of the Smif it here which is going to be streamed by
you and the name of the Smurfette is going to be match with minimum minimum confidence level of user.
User words.
Right.
Let's put our performances here because we are going to actually specify that this method is going to
accept some arguments.
So let's specify those parameters here inside the practices of this method here.
So the first argument is going to be released.
OK let's put a pair of angle brackets here and inside the angle brackets we need to specify that data
type of the objects that we are going to have inside this list.
So it is going to be strange.
Right.
So let's actually put our space here and I'm going to specify the name of this allele which is going
to be used for words.
Come on now let's specify the second argument.
The second parameter actually.
So now let's actually specify the second trimester of the Smurfette here which is going to be an array
of floats values.
So just type in here float and and then put a pair of brackets in order to specify that it is going
to be an array of floats values.
And then here the name is going to be confidence confidence levels.
Right.
So let's open and close this method by using these curly braces.
Let me create a new line here so that you can see what's going on.
Yes.
These are my faith here inside this class country data source class public street.
This is the return type of this method the name of this method is much a match with minimum confidence
level of use or words.
This method has two prime hitters here.
The first one is the use of words which is of type aerialist here strange and we have this a float values.
Your confidence levels.
So these are the two prime tools of this method.
So now it's time to go inside the Smurfette and we are going to actually put our own logic here inside
the curly braces of this method.
So first of all we're are going to check that whether these two arguments that are going to be passed
here to the Smurfette are actually null or not.
So let's create an if statement.
If user votes as you can see I am referring to this parameter name right.
Is equal to null or.
And then here I'm going to refer to this confidence levels argument here.
So confidence levels is equal to null then in that case are going to return a string value from this
actually nymphet.
So you are going to return the default country OK because if the user course is actually not all the
confidence level is actually null This means that we have not access to and to a specific Vort.
Right.
So in that case you're are going to show that Canada on the map to the user.
So let's return.
Default actually the default country name semi-colon.
So let me show you the instance variables that we created here you can see that we created some constants
here.
The first one is the country key.
We have the minimum confidence level.
We have the default country name Canada default country latitude longitude and the default message.
So let's scroll down here.
So after this if statement here inside the Smurfette I'm going to put some more color codes here.
So let's create an integer variable here int number of user words.
Number of use of words.
Assignment operator.
So I'm going to refer to this Aurelie still use the words dot and then I can actually call this method
and this Aurelia's size semicolon.
So in this case it can actually return the number of elements that we have inside this list and it's
going to assign those elements actually the size of those elements.
The number of those elements to this valuable number of user words.
So now let's actually create some space here.
I want to talk about the enumeration interface.
First let me show you the documentation here.
So let's open the Android actually documentation on your web browser.
So now you can see that I actually searched for the enumeration interface and this interface is inside
a job that U-T package.
So here you can see this link here.
Let's click on it.
So now it says that the enumeration is actually an interface a public interface.
And let's look at it this description he had an object that implements the enumeration interface generates
a series of elements one at a time.
OK.
So it is very important a series of elements one at a time.
Successive calls to the next element before the return the successive elements of the series.
So here you can take a look at an example here and let's look at the other descriptions here.
It says methods are provided to enumerate for the elements of a vector.
The key is of a hash table and the values in a hash table.
Enumerations are also used to specify the input streams to a sequence input stream.
Note the functionality of this interface is duplicated by the rated iterator interface.
In addition iterator adds an optional remove operation and has short term effect names.
New implementations should consider using iterator in preference to enumeration.
So let's actually look at the summary here.
It says we have this method has more elements tests.
If this enumeration contains more elements next element returns the next element of this enumeration.
If this enumeration object has at least one more element to provide.
So let's go back to android studio here.
So here it is RMF at match with minimum confident confidence level of use of words here inside this
country data source class.
So instead method.
After this line of put here in line number 43 here you are actually getting the number of elements that
we have inside.
Is this right.
Let's create an enumeration here.
So here we can say enumeration OK let's put a pair of angle brackets inside the angle brackets.
When it is specified the data type of the values that you're going to have inside this information.
So it is going to be strange and the name of this enumeration is going to be countries here let's create
a for loop and first of all we need to specify the initial value which is going to be of that integer
and the name is index set and then let's initially assign the value 0 to the value of a semicolon.
So here we need to actually specify the condition that determines how many times this fall is going
to be executed.
So here we are going to actually use two conditions instead of one.
So let's see how we can do that first.
I'm going to say this for loop it's going to be executed until the value of the index variable is actually
less than the number of user words.
So let's step in here.
Number of user reports and I am actually using these and the logical operator index is less than the
value of these confidence levels that Len.
Actually we are good at accessing the length of this Arey which is off the floor.
So here I can refer to these arguments name confidence levels that lead and index is less than that.
Actually the length of this at a confidence level is here semicolon.
And finally we need to say index plus plus.
So let's open and close this followed by using these curly braces.
Let me create a new line here so that you can see what's going on.
Yes exactly.
So let's go inside this for loop here and let's see what you are going to do next.
So here we are going to say if let's actually refer to these confidence levels at a if confidence levels
practice index.
So here we are going to access this specific element.
All these specific confidence level that we have inside this specific index.
So for example for the first time that is full of here it's going to be executed the index value is
zero.
So it's going to go inside this at a confidence level and it's going to access the value that we have
inside the index zero.
And here you are saying that if confidence levels index zero is less than actually mean and minimum
confidence level here.
So we created a variable and actually a constant here inside our class country datasource here in line
number 16.
Right.
So you can see this line of code and here you specify that the minimum confidence level here is zero
point four here.
So it is actually a float value.
And this is going to go in to specify the minimum confidence level.
And this means that values below the confidence level are not actually accepted.
OK we're going to break out of our Meffert if the specific value is actually below the minimum confidence
level.
So the minimum confidence level must be actually equal to this value or greater than this value not
below the value.
Right.
So here you can see that I actually mistakenly created a pretty good point here.
So in order to deal with this point I just need to click on it.
OK.
In order to create it again I just need to click on the site.
And in order to do it I just need to click on it again.
So let's scroll down here.
So if you're I mean set is meant for the writing so it is match with minimum confidence levels a level
of use that it words.
And here I am saying if confidence level index is less than minimum confidence level so it is not accepted.
Here we are going to say.
So it's going to break out of the sniff at here.
This effort that we actually created here.
So after this if statement here I can't say.
So let's create a variable of type string here.
So just typing here is strange string and the name of this variable is very important.
Just taken he had accepted user vord.
You can see that I am actually choosing a name meaningful here right.
Accepted user or assignment operator.
So here I can refer to this at a list here that we have as an argument.
So here I can't say user votes that get and here I just need to pass the index semicolon.
So in this way we are actually accessing the accepted user word according to that minimum confidence
here that is specified here right.
So according to this minimum confidence level it is going to actually get the accepted user award here.
According to this index right a specific word that is really related to this index and it's going to
slide this forward to this very well accepted use that word.
So after this line of quote here I'm going to actually initialize this valuable this local variable
that we actually declared in line number 47 here inside the Smurfette.
So I can actually say countries assignment operator.
So let me scroll to the top here.
Here you can see that he created a variable of type hash table.
So I told you hash table consists of keys and values.
So we have keys and values and this means that a specific value is related to that specific key.
So here inside the angle brackets the first string here is actually related to the data type of the
keys that we are going to have inside this hash table.
And the second string here is related to the data type of the values that we are going to have inside
this hash table.
So the name is countries and messages.
So you can see that its name is really meaningful.
Countries refer to the actually the key and messages referred to the value.
So let's scroll down here.
And inside this here I'm going to initialize this country's information here right.
So I can refer to that hash table here countries and messages that cheese.
So I'm going to access the keys of this hash table variable.
So the keys are countries right.
So that's why I am assigning the keys to this variable and you can see that its name is countries information.
So after this line of code here.
So here let's create a loop so void.
And here I'm going to refer to this integration here countries that has more elements has more elements
here I am saying that if this country's information has more elements we are actually saying that if
this country's in question actually does have for example some elements inside it OK if it is whether
it is empty or not if it is not empty and it is and it has more elements then we are actually going
to open and close this window by using these curly braces here too.
Now let me show you the documentation.
So here you can see that the summary here and it says has elements Mefford.
And it says tests if this enumeration contains more elements.
So let's go back to Andrew in Studio inside the curly braces of this y loop so here can create another
value of types 3 in here.
And the name is going to be selected.
Country assignment operator and here I can refer to this enumeration countries.
That next element semicolon Let me show you the Android documentation.
So take a look at this map with your next element returns the next element of this information.
If this enumeration object has at least one more element to prove what.
So it's going to actually give us the next element to the specific elements that is available and it's
going to assign it to this variable selected country and now it's time to create another if statement
inside this way.
So if and here I can actually refer to this user word valuable that we created here.
Let me show you this right here and here.
Accepted use of word.
Right.
So if accepted use that word that equals ignore chase.
So what is this.
If it means this me if it means that if this accepted use or what string value is actually equal to
another a string value that are going to pass that is MF'er.
So what does this case mean here means.
This means that the leaders of this accepted use or word here are actually according to the case.
For example if it is capitalized or it is lowercase it's going to ignore it.
OK if it is capitalized it's going to ignore the capitalisation actually aspect of this word.
So it's going to ignore the case and it's going to actually it doesn't matter whether it is lowercase
or capitalized it can actually just compare whether these this accepted use or word is equal to the
selected country.
OK then in that case it's going to actually open it it's open and close this if statement here by using
these curly braces.
So now let me show you this method in the Android mentation.
So here just into this you are a developer and writer slash referenced slash Java slash land slash string
that HDMI out.
So here I searched for the Smurfit equals ignore case.
So you can see this buffer here and it says compares this strange to and other streams ignored into
case considerations.
This is very important.
Ignoring case considerations.
So let's go back to our studio at this if statement here.
We are actually a hundred and fifty percent sure that the accepted user vote is actually equal to the
selected country.
Right.
So now we can actually return accepted user award from the Smurfit accepted user worth semicolon.
So now finally here you can see let me show you the effort here.
The return type of this method is strange.
Right.
We're going to return this specific string value that is actually matched with minimum confidence level
of the user rewards.
So here we are going to return the accepted user vote.
But what happens if for example these these conditions fail.
What happens if this condition that you specified for this fall of here fail.
And this fall doesn't go into it is not going to be executed anymore.
In that case you're going to return the default country from the Smurfette.
So here if you scroll down here you can see that this is the end in place of the Smurfette.
Right.
And here we have an error and it says missing the return statement.
We must return a value from this method but it doesn't matter what happens.
OK we must return osting value Firby-Smith and the compiler must be sure that our value osting value
is going to be returned from dismissal.
We can actually return now we can say return not for it.
Let me just type in Knol but it's not accepted here right.
If you return not from the Smurfette.
Later when we are actually calling the Smurfette And for example if we want to get osting value from
this method and it's going a little not probably Smurfette in that case we are going to have problems
on our application it may actually crash.
So if you are going to return as a default string value which is going to be the default country name
semicolon.
Right that's it.
This is our method.
This is my foot inside this class.
So now it's time to add another method to this class country data source.
So before the end in curly brace of this class country datasource and Asadi an incredible test of the
Smurfette here let's add another method to just type in here Puplick and then return type of this method
is going to be strange and the name of this method is.
Get the info.
Get the info of the country.
So let's put up at Apprentice's here.
So if you are going to pass actually an argument is my fair lady when we are going to call this method
so let's specify the prime meter here.
So the parameter is going to be of type strange and the name is going to be country.
Let's open and close this method by using these curly braces.
So here I can trn.
So let's refer to our hash table instance variable countries and messages.
So here we want to pass the key and get the value and we all know that the country is the key and the
message or the info from that country is going to be the value.
So here when I say countries and messages that get Let's call this method get.
So here you can see that we need to pass the key which is going to be OFF-SIDE object right.
So we all know that's three and is a subclass of object.
So if I pass the country here as an argument to the Smurfette semicolon So here it is the key right.
So when I pass the key when I get the message or the info from that key that's it that's the actually
function of this method.
So let's actually look at this class here.
Here you can see that we actually created some constants in this class and we haven't used them yet.
You are going to use them later.
Don't worry about this one.
But for now just know that we have these constants and you can see that these constants are actually
static.
Right.
This means that by just referring to the name of this class you can directly access these constants
because they are static.
They are actually class variables so that's it.
And I think that's enough for this tutorial.
If you have any questions about the concepts that I taught you in this lesson please post the discussion
in the course and then I'll do my best to answer all of your questions.
Thank you very much for watching and I'll see you in the next tutorial.