So now I'm going to paste in some lines of code here and then I'm going to explain to you what's going
on here.
So as you can see here these are the lines of code that I pasted here and now I'm going to try to explain
to you what's going on here.
Exactly.
So now let's actually look at our Meffert here.
So the access modifier of arms if it is private the return type of RMF it is void.
And as you can see the name of RMF it is show next animal right.
So the job of the Smurfette is to actually show the quiz actually question the picture of the animal
and the quiz questions are actually the guest buttons and then we can actually see the question and
then we can answer the question right.
So that's the only job of this method.
So now let's actually go inside the curly braces of the Smurfette And let's see what's going on here.
So in line number three hundred twenty nine as you can see here we have actually a variable which is
of type string.
Right.
So the name of this variable is the next animal image name.
Right.
So this variable is going to hold the actually the name of the animal image that you're going to show
it to the user.
So if it's an assignment operator here and then I actually first released animals names quiz list so
this list is actually supposed to actually hold the images.
OK.
The animal images that you're going to have inside our quiz.
So animal names quiz list dot remove.
Index 0.
So this means that it's going to actually remove the value that is inside of the index zero of this
list.
Animals names quiz list and then we're going to actually assign that removed value to this next animal.
Image Name.
So now we actually moved the first value that you have inside our least.
OK so this list is going to hold the animal image names that you're going to show to the to.
Right.
So you're going to actually first of all remove the first value that is inside of the index 0 and then
you going to actually assign that remove the value to the next animal image name which is a five string
right in line number 350 as you can see here are you referred to the name of this variable is going
to hold the actually the correct answer.
The correct answer to the first question.
So let me actually show you the emulator and then and then I'm going to talk about that here.
So now you can see here our application is running on this emulator.
And now for example this is actually the first question that is actually shown to us.
So now as you can see here we're going to actually first of all remove the first value that we have
inside our quiz and then we're going to assign that value to the next animal image name.
And then here this variable which is supposed to actually hold the correct answer of every question.
So as you can see here this is our first question right.
This is animal one of 10 and this very Abella correct animals answer is actually a variable of type
three and that is supposed to hold the correct answer of every question that we actually ask from the
user.
So as you can see this is the first question here.
For example this is actually a rabbit right.
So here we should actually choose the rapid Libet here.
So the correct animal's answer is going to actually hold this rabbit.
Right.
And then first of all because this is actually the question that you're showing to the user first you
need to actually empted is why you hear the answer to the answer that it takes.
This is actually an empty value.
So now this valuable correct answer actually holds this value rabbit.
And now let's actually look at this line of code here.
It is like number three hundred and thirty free.
The question numbered.
So he asks the question number is this takes here.
This is animal 1 for example of 10.
So this is that he asks the question number that said text.
And then I called the Smurfette here to get the strength.
And if I actually hold the comments on my keyboard if you are using a Windows machine use actually to
hold the controls on your keyboard and then click on this three inch My here as you can see we actually
get this method from the fragment of a file as he can hear from the fragments class.
So Nalut me actually close this fragment of a file here.
So it gets strange.
And now as can see here this method here actually accepts free arguments.
The first argument is the actually the string value is this resource value so all that string that question
underlined text.
So anality actually go inside is strings that exemplified all I can actually hold are the comment on
my keyboard.
And again if you are using a Windows machine just hold the control on your keyboard and this rally you
hear question underlying text.
And now as you can see here you can actually see this value here inside these strings that exemplified.
And this is actually a stunning resource question underlined text and this rather is this I hold this
value.
This is animal so percent want dollar sign the means this is actually the first argument which is of
type integer.
And of person two dollar sign the means actually this is the second argument that actually is an integer
value.
So let me ask you to go inside this main activity fragment of a file.
So as you can see here for the first argument right for the first argument which is this value here.
Number of right answers plus 1.
So initially when we actually start our quiz application the value of this number of right answers value
is actually zero right.
Initially the value of this number of answers variable is zero because we just started our application
here and now we want to actually say that number of answers plus 1 means that this is actually given
here for example.
This is the number of answers here is 0 0 plus 1 is 1.
So here it's going to actually put this value here.
This is animal 1 right.
And then as you can see here number of animals included inquiries.
So this is the number 10 here.
So here as you can see we're going to have 10 questions right.
10 animal images here so that you use that can actually get the name of these animals.
So that's the purpose of these of these two lines of code here.
As you can see and now in line number three hundred and thirty six we have another line of code here.
And now let's actually look at this line of code here.
We have actually a string value but then name of my string about eleven is animal type.
I put an assignment operator here and then as you can see here next animal image name right.
Next animal image name that substrate.
And as you can see here this method substring is going to actually just separate are symbols.
So for example here next animal image name that substory is going to give us a substring of the set
of a string value that you pass to this method.
So this will let me actually just show you these arguments of this Moffit next.
And in one image name that substring.
And now as you can see this if it accepts two arguments the first one is actually an integer.
And then in this BGN index and the second argument is actually again of type integer and the name is
an index.
So here we can actually specify the beginning index and the ending index of of this string value that
we pass through this method and then we can actually get the remaining starting value.
So now for example let me just add that it's this line of code here.
So as you can see here we're actually specifying the beginning index which is actually zero.
And then if you are specifying the ending index.
So people I tell you about this piece of code here.
First let me actually tell you about the purpose of this line of code here as you can see we are actually
getting that type of the animal which is actually the answer right.
So now let me show you the emulator as you can see this is the image that you're showing to the user.
So we should actually put this image to the user and we should actually get this image from the actual
assets folder.
Right.
So when you want to load this image and when we want to show this image to the user first we need to
actually get the type of the animal that you are actually dealing with.
So here we are actually leading with our rabbit.
So that type of this animal is for example a tame animal.
So now let me show you the structure of the project.
Just click on view to tool those and then project and now as you can see here inside the structure of
the project inside these assets folder we have two folders.
The first one is PAME underline elements and the second folder is void.
Underline any months and when we want to actually show the image.
OK so for example when the show and animal method is called We need to actually get the image of the
animal that we want to show to the user and we need to actually load it here right.
So first in order to do that in order to actually load that image here we need to first get the type
of the animal so that we can actually go inside these assets will there and then go inside that specific
folder paper underline any months or voyde Underland any months and then we can actually get that specific.
For example image so as you can see here this is actually our tame animal.
So you can actually go inside these tame Underland animals and then we can actually find this animal
here.
But look at this animal name here.
Look at the name of this image came under like anemones dashed rabbit.
Right.
So let's look at this line of code here.
As you can see here we actually created a thing valuable and the name is animal type.
So the purpose of this rally is to get the animal type.
I put an assignment operator here.
And then you referred to the name of the value.
Next animal image name.
Right next animal image name is the value that we actually created.
Here's in line number three hundred twenty nine right.
So now next animal image name that Suppes dream.
So we call this substring method.
On this next animal image name.
So that this is going to give us a substring of the string that we call this Mefford on.
Right.
So next animal is named that substrate first.
We are actually specifying the beginning index.
So the beginning index is actually the first actually the first character of this name.
So as you can see here the first character of this name is that is the character t.
Right.
So it's going to actually start from the beginning index which is actually this value here.
This index 0 which is this right.
And now we need to specify the ending index.
So as you can see here for the second argument here I am specifying the ending index.
Next animal image name dot index of dash as you can see here.
It's going to actually look at this name here and it's going to actually find the stash here.
As you can see so the beginning index is T and the ending index is this is the stash here right.
So this method here is this substring Meffert is going to actually give us.
There actually is string value that starts with T and ends with this end in each index which is actually
the stash character but not including this character.
So this is just going to actually give us disvalue that starts with T and just ends with this ending
character but not including this ending character.
And he says I'm going to ask you to give us this value and then it's going to actually eliminate the
remaining part which is this rabbit that PAGG.
So in this way we can actually get this animal type right.
So now that the animal type is tame under live animals and then it's going to be assigned this videotape
Underland months to these animal type.
So let me explain again here what's going on.
Next animal image name that substring.
So it's going to give us a substring of this thing value that we pass to this method and here as you
can see first we are specifying the beginning index.
So the beginning index is t.
And here we need to specify the ending index.
So next animal image name dot index of dash.
So the index of that is here and then it's going to give us this this thing value that starts with T
and ends with dash but not including the character.
And then it's going to give us only That's value.
And then it's going to actually assign that value to the animal type.
So in this way we can actually get the type of the animal here.
So now the type is animal is actually tape on the line.
For example in this case we can see that this is actually a rabbit.
So that type is tame Underland animals.
So hopefully that makes sense.
And now let me actually double click on this tab here in order to make this area vital.
And now let's actually look at the other lines of code here.