So now let's actually look at these lines of code here in line number two hundred and twenty nine as
you can see here.
I actually referred to the name of this variable number of right answers.
Assignment operator zero.
So when I want to actually reset our quiz application.
I want to actually assign the value zero for the number of right answers because in that case we are
not going to have right answers because our application.
Actually our quiz is actually reset.
So again we have this number of all guesses valuable.
And again we assign the values zero to the number of all guesses variable because again we are actually
resetting our cuius application.
So we want to assign the value zero to these variables.
And if you actually scroll to the top here as you can see if you actually declare these two variables
here.
Number 45 I declare this variable here a number of all guesses.
And we also declare this valuable number of right answers.
So this number of all this is is going to actually hold or the number of times that the user actually
guessed there actually questions.
And this number of answers is going to actually hold the number of times that the use guessed at the
right animal.
OK.
Just at the right.
Just the name of the animal right.
So hopefully that makes sense.
And now the texturally scroll down.
And let's actually go inside this actually inside this recent animal quis Smurfette.
And here we have these animals names cuius list.
So we have this Actually we have this arii But this is actually a list that can actually accept an array.
And again lists are actually interfaces in Java and we use the least because we want to actually use
the extra features that come with the list interface.
So now if we actually scroll to the top here as you can see we actually declared these animals names
quiz list here as you can see.
So this variable is going to actually hold the number of actually the animals that we have inside our
quiz.
So now if I show you the emulator here as you can see let me actually show you the queries as you can
see.
We have we are going to have 10 questions right.
So this means that we are going to have 10 randomly selected animal images from our project.
And then it's going to actually show us those images to us.
So if we have two variables to list actually the first one is all animals names list.
And the second one is animals names quiz list.
So this all animals names list.
So for example let me show you the emulator if I actually go inside these settings activity and then
here anemones as you can see if they use that actually specifies that he or she maybe wants to for example
only have paint animals sight our quiz.
Then in that case if they use that actually selects this tame animals here then the animal images inside
the inside the actually came Underland animals fall there.
So now let me show you the structure of the project inside it is tame Underland animals folder.
These images are going to be actually assigned to these and all animals names list.
OK.
Or if they use that actually to select both of these checkboxes here this means that the user wants
to have all the images that are inside of these folders.
Wild animals and tame animals.
So in that case that means that all these images are going to be assigned to these other animals names.
So I showed you here inside these actually let me show you this method here.
We said animal Chris as you can see inside is for a loop.
He actually said that we want to add all the images all the image paths that we have inside our animal
types inquiries.
So here you are specifying the animal types that we want to put inside our quiz.
Right.
So in that case it's going to actually assign all the image paths to art at all.
Animals are actually all animals names list so that all animals names these are going to is going to
actually hold those image paths.
But we have these animals names these.
So this malleable this list is going to hold only the selected only randomly selected images that we
have inside our quiz.
So for example as you can see we have 10 only 10 questions right.
We have lots of images but we are going to have only 10 questions and this means that if you want to
actually use these images if you want to only have 10 questions in site Ahlquist we need to actually
randomly select our 10 images from these folders and then we can actually put put that here.
So these animals names quiz list right Ebell this list is going to hold that randomly that images those
randomly selected images.
So hopefully that makes sense.
And now let me I actually double click on this tab here main activity Fleischman that Java tab and now
let's actually scroll down here and again let's actually go inside this reset animalcules Mefford.
So as you can see here because we want to actually do reset our animal quiz we need to actually clear
all the values all the images that are inside of these animals names.
Is this here first.
And then here as you can see in line number two hundred and fifty three I created over the table which
is of type integer and the name is counter.
And then initially I assigned to devalue number one to this counter in line number 254 as you can see
here we created another variable and the name of this variable is number of available animals.
OK.
Number of available animals.
And this means that this variable here is going to actually hold all the number of animals that are
actually available to to the queen.
So for example Now let me show you the emulator.
And now I want to actually go inside the settings activity and now I choose these animals.
So here I can actually specify that what types of animals are going to be inside always.
So now it would only select only tame animals.
If we only check this checkbox here.
This means that we have only the animals that are inside of these tame Underland animals folder.
So in other words only the images that are inside of this tape Underland animals for there are going
to be available to us and this valuable as you can see here a number of available animals this valuable
is going to hold the number of images that can be actually used in insight or Kiwis or here if we actually
also check the search box here.
This means that though the number of animals that are going to be available are actually always going
to be also these animals here that are inside of this world under like animals so hopefully that makes
sense so in that case all animals names list.
So about this list actually holds the animals that you specified and then adding on elements names.
These thoughts cise.
So here is going to actually give us the number of animals the size of this list and then we can actually
assign that size to the number of available animals valuable.
So hopefully that makes sense.
And here as you can see we have a void.
Right.
So let's look at this while up here and let's see what's going on here.
Here if you say wild counter so as you can see here we created these counter-rally label in line number
two hundred and fifty three vial counter is less than or equal to number of animals included increase.
So now if I actually scroll to the top here as you can see inside this class if you actually created
this constant as you can see here a number of animals included increase.
And then I assigned the value number 10 to this constant And this means that we're going to have 10
questions 10 animals in sight always.
So as you can see here if I click on dispatch button here as you can see it says this is animal of one
of 10.
So this means that you're going to have 10 questions 10 and months.
Right.
So let me scroll down here and let's actually again go inside our my favorite is that animal quis.
So here as you can see let me show you the loop here.
As you can see so until vide the value of this counter which is now one is less than or equal to a number
of animals including the inquiries which is 10 then it's going to actually go inside the curly braces
of this for a while loop and then it's going to actually execute the lines of code that are inside of
the white tube here.
First as you can see here we actually created vit where it's going to recreate of the of type integer
and the name of this variable is a random index.
Right.
Assignment operator and then I refer to the name of this variable secure random number.
So now if we actually scroll to the top of the file here inside our main activity fragment class as
you can see here in line number 48 by actually declared this variable which is of type secure random
and this variable name is secure random number.
So the job of this variable is actually to hold a random number or secure random number.
Right.
That's the only job of this value.
And then here as you can see inside this main activity for fragment in line number 70 I am actually
initializing this rowdier but your random number assignment operator new secure random number.
So now we have as truly an object of type secure random that can actually hold on a random value right.
So let's actually go inside our Richard Quest Meffert And let's see how we can use this secure random
object.
So now inside this loop here random index assignment operator secure random number.
That's next.
And so by calling dismay at the next int as you can see here we can actually get our random integer
value.
And here it says not are actually assigned number of available any months.
So it's going to give us a value between 0 and the value that we specify here.
Number of available animals.
So the number of available animals is going to be of value that is specified here.
All animals names these sites.
Right so for example let me show you the structure of the project.
So for example inside tame animals for there if we specified that we're going to have only tame animals
in sight always.
Then as you can see here for example it's actually count the number of images that we have here one
two three four five six seven eight 9 10 11 12.
So we have 12 images inside this team Underland animals folder.
So this is going to be 12 for example.
Right.
And now it's going to actually give us our random value secure and the next.
It means that it's going to give us a random value between 0 and 12 right.
And then it's going to be assigned at random value to the standard index.
So now as you can see here in line number 240 as you can see we created another variable which is of
type String animal image name.
This is the name of this valuable assignment operator here.
And I actually further to the name of this list here.
All animals names the list dot get a random index right.
So here at this piece of code here it's going to actually give us our random value or random image path
as you can see here.
Let me show you the structure of the project.
For example we have specified that we want to only have tame animals inside our project as you can see
here.
All animals names these.
And now actually contains these images right dot get a random index so you can actually randomly select
one of these images.
For example this flappy bird and then it's going to actually assign that value to this animal.
Image Name which is actually of type string.
Right.
And now as you can see here we have actually an if statement.
So if I need molls names quiz list that contains So as you can see here I put an exclamation mark here.
Right.
So this exclamation marks me here means not if animals names quiz list does not contain animal image
name as you can see here.
So here we have an if statement and this statement here means if animals names cuius least if the animals
that are going to be inside our quits as you can see here these animals names quizz this this list is
going to actually hold our randomly selected images that we have inside our coolies.
So here we are going to have only 10 questions right.
So if this list does not contain as you can see here this exclamation mark here means not if animals
names This list does not contain animal image name as you can see here.
So here we are taking that we are not going to for example add a duplicated image value a duplicated
image to always right.
We're going to have every time that we actually answer a question the next question is going to be a
different question or different animal.
So here we are saying that if it if the image that is actually inside our animals names because this
is actually the same as animals.
Image Name here as you can see then it's not going to actually execute this statement.
Here we are thinking that if animals names This list does not contain animal image name.
So if we don't have duplicated our image inside our quiz then it's going to actually add that image
to these animals names quizzes so animals names quislings start at animal image.
Right.
And then it's going to increment the counter by Yvonne.
Right.
So here for example because we're going to have only 10 questions inside our quiz.
So the initial value is 1.
So it can actually increment this counter.
And then until until it reaches to the value for example Number 10.
So here we are checking that until the value account is equal or let Actually it is actually less than
or equal to number of animals included in quiz.
So until it reaches to the number 10 and then it's going as it should is why look.
And when it reaches to the value in number 11 as you can see here it's not going to actually raise it
this way.
And it's going to keep this piece of code here and it's and then it's going to actually show the results
to the user.
So hopefully that makes sense.
And we have also the Smurfette show next animal which we are going to add later but for now I want you
to actually just look at these lines of code here that we put inside this wretched animal cookies and
just figure out what's going on here.
Right.