So here I can just take Pontiac's the five stars student that said text and inside Apprentice's I need
to just be fair to the name of the five stars review.
OK.
Plus two double quotes.
OK.
Again just typing here takes the Forresters student that said text for star review plus two double quotes
takes the freestylers student that said text free starts review plus two double quotes TXI the two stars.
Student That said text to start a review plus two double quotes takes the one to start student.
That said text one star review plus two double quotes.
OK so now let's actually run our project and see what happens.
So as you can see here our application is actually running on this emulator and here as you can see
it let's actually click on this.
Show me the results button here.
In order to see what's the results.
OK.
As you can see here these values are from these student reviews.
OK.
And here we are actually to reading these values and we are saying that we have four students with five
star review.
We have two students with four stars of The View.
We have four students with of The View.
We have two students we have three students with two stars of The View and we have one student with
one star review OK.
And here we are actually reading the values that are actually inside of the students reviews and we
are outputting those values to the screen.
OK.
OK everyone.
As you can see here our application is actually working right here on the simulator.
But are there is a really nasty bug in our application.
If you actually click on this or show me the results button here again let's see what happens.
Oh as you can see the values changed.
Eight for eight.
And again the values changed.
So that's not right.
That's that's a bug in our application that these values should not be changed.
OK because we are reading these values from these of them that are actually inside of these students
reviews.
OK.
As you can see here the problem occurs when this for loop is executed in sight of this of unclick Meffert.
OK.
So when you actually click on this button first of all it's going to actually execute this for a loop
here.
OK.
As you can see here it is inside of this for loop.
We have actually put some if statements here and inside.
And here I am saying that for example if students reviews up in the x is equal to number five plus plus
five stars review then it's going to actually go inside of this array.
And if it finds for example a value that is equal to this number five then it's going to actually increment
the value of this a five star review by one.
OK.
And then it's going to actually outputs that value to that screen.
OK.
So that's why we can see that these values are changing here.
Why.
When we actually click on the spot in here OK.
Because every time that we actually click on the spot and I try to execute this follow up here and then
it's going I try to go inside this follow up and then when it finds a value that is inside of this array
and that video for example is of equal to this number it can actually increment the value of these variables
that we created here.
OK.
And here we are actually outputting the value of these variables to the screen.
OK.
So there are three solutions to this problem.
OK.
The first solution is actually after executing these lines of code after this follow up after this for
loop and after executing these lines of code here.
OK.
So here I just into typing between results that said visibility view that invisible.
So now as you can see here I am actually putting this line of code here after executing these lines
of code here after executing this for loop.
And then after executing these lines of code here it's going to actually make the spot in between results
invisible so that the user can not interact with that button anymore.
So let's actually run our project and see what happens.
So as you can see here our application is actually running on this emulator on here.
If you actually click on the spot and let's see what happens.
Now we can see the results here and now that button is gone.
OK.
So as you can see here now that button is when is invisible and I cannot interact with that button anymore.
So these are the results here.
And as you can see we've got four students with Fife's with five star review.
We've got two students with our four star review.
We've got four students with us.
We started freestylers review and we've got three students with two stars review.
And here we've got one student with one star review.
OK.
As you can see these are the values that are actually inside of this array.
And here I am actually reading.
Those are values here as you can see and out putting those values onto the screen here so hopefully
that makes sense.
And there is another solution to this problem too.
So let's actually go back and say this main activity dodgeball fight here and let's actually comment
out this line of code here and here inside of this main activity class is actually create a boolean
variable.
Bullion and the name of this variable is first time.
And then let's actually assign the value.
True.
This right here.
Well OK.
And inside of these are set on calculus and are here as you can see inside of this method as you can
see inside of this ugly Smurfette.
Now I can just create an if statement here.
OK enough first time.
OK.
If the value of this first time value is true OK then we can actually put these lines of code here.
These are for loop inside of these first time OK.
And here after this for loop after the end in curly brace of this for loop here I can actually assign
the value false to this first thing but first time assignment operator false.
OK.
So now it's actually on our project and let's see what happens.
So as you can see here now our application is actually run in an emulator.
And here if you actually click on this show me the result spot and let's see what happens.
As you can see now we can see the results here.
OK.
So let's actually click on this button again as you can see these values actually don't change here.
OK.
If I click on this button here now you can see these values are actually don't change and our codes
are actually working right.
OK.
So here we actually created a boolean variable first time and I assigned the value true to this value.
And inside of this Meffert I said that if first time valuable is true if the value of these first time
is true then execs used these lines of code.
Here it is for loop.
So the first thing that we actually click on that button on this.
Show me the results button.
The value of these first time valuable is true.
OK.
So then it's going actually execute this for a loop and then it's going to actually increment the values
of the values of these variables.
For example this five story finally starts really valuable according to the value that is actually inside
of the index of that student reviews array.
And then after executing this for loop after the ending are curly brace of this for loop we set that
first time assignment operator for us.
So the value of this first time variable is now false.
So and then we can actually execute these lines of code and then it reaches the end in calibrates of
this method.
And it going to actually output those values to the screen as you can see these are the values.
OK.
So now the second time that the user clicks on this button as you can see here now again it's going
to actually go inside of this method.
And again it's going to check this condition if first time value bet is true.
So as you can see here we assign the value falls to this valuable.
So now when we when we actually click on this button the value of this first thing valuable is false.
So it's not going to actually execute this if statement here and it is going to only execute like these
lines of code here.
OK.
As you can see here we could even actually put these lines of code inside of this if statements.
So let's actually delete this.
And in calibrates of this if statement as you can see here and we could actually put it here.
After these lines of code here.
And let's actually do our project again and see what happens.
So as you can see here now our application is actually running on this emulator.
So let's actually click on the spot in here and let's see what happens.
As you can see now these values are here.
And let's actually click on this button again.
Now as you can see these values don't change any more.
OK.
So hopefully that makes sense.
And there is another solution to this problem.