This sexual comments out this statement here and these are ending curly brace of this statement and
so and we could actually put this for statement put this for a loop outside of this enclave.
OK.
And inside of the uncreate effort so that the execution of this for loop would happen only once.
OK.
So let's actually copy this for a loop here and let's actually put it here out after these students
reviews re.
OK.
And then let's actually comment out the for loop here inside of this comfort Comerford OK.
And this uncreate my fate is going to be actually executed only when the application is actually run
by the user when the user actually touches the icon of the application in his or her phone.
And then our application starts in that time.
These are uncreate me if it is going to be executed.
OK.
So let's actually create a toast in order to show you that when this effort is going to be caught our
toast is actually a way in order to actually show a message to the user.
OK I talk more about hosta later in this course.
But for now remember this is this is actually our way in order to show and to show a message to the
user.
So here inside of this uncreate Meffert here for example I can just type in toast that make text.
So here we need to actually specify our free argument.
OK.
So for the first argument just type in here is come on.
And here we need to actually specify the text that I want to show you to the user.
So here I just put into double quotes as you can see here the type of these are valuable is Chad sequence.
So if we could just put into double quotes and here I can just typing uncreate Mefford is caught.
OK.
Comma and here we need to actually specify the duration of this message.
So here I can just type in toast that line long.
OK here after the ending of round in Brachet of this Mefford I could just type in that show.
OK.
Here I called the show Smurfette and this tossed here.
OK.
And let's actually do it on our project and see what happens.
So now let's actually run our project and see what happens.
As you can see here now we can see this Meffert.
This message here uncreate Meffert is called Let's actually click on the spot in here as you can see
here.
We put this for a loop here.
Inside of this uncreate my faith and after that for a loop I actually called this that unclick lesson
and my friend on the spitting results OK.
And here we are actually putting these lines of code in order to show all of these values to the screen.
So let's actually click on the spot and let's see what happens.
As you can see if you can see these values here.
And let's actually click on this button again as you can see here these values don't change any more
here.
OK.
This for loop is going to be executed only once.
OK.
And then inside of this are certain calculus and an Mefford in say that his uncle.
I'm afraid we can't see.
We just tried to output these values the values that are actually inside of these of variables to the
screen.
OK.
So hopefully that makes sense.
Let's actually comment out this for a loop here because I want to show you another way in order to actually
write your codes.
OK.
I want to show you to use actually switch instead of if statements in order to actually specify the
correct values and outputs those values to the screen.
OK.
So here as you can see we commented out this for a loop here.
Let's actually uncomment this for a loop.
OK.
And now let's actually uncommented this statement.
This is a first time statement here.
OK.
I think this is the best solution for this problem.
OK.
And uncomment this first time valuable here as you can see we assign the value of false to the first
time.
And here uncomment the end in curly brace as you can see here of this statement.
So now let's actually comment out these of these statements here OK.
As you can see here now I want to actually use the switch statement in order to actually specify the
correct values and output those values to the screen.
OK.
So here again just typing sweet.
OK.
And inside the apprentice's I can just type in student reviews brackets and inside the branch brackets
I can just refer to the name of the index variable.
And here I can just open and close my switch statement by using these curly braces.
So instead of the switch statement as you can see here I can just type in chase.
OK.
Case 5 colon.
OK.
Plus plus five stars leave review.
OK.
Semi-colon break.
And here what I am saying is switch between the values of these students to use some index.
OK.
So for example for the first time that this loop is going to be executed the value of this index variable
is zero.
And here is when I try to check this condition.
So 0 is less than the value of the length of this student reviews array.
OK.
So you can actually go inside of this for a loop and then it can actually execute this switch statement.
So here we are saying that switch between the values of these students revues sub index.
So the value of the index for the first time is zero.
OK.
So student reviews sub zero as you can see here that this means that the value that is inside of the
index 0 is for example.
As you can see here five number five.
OK.
So as you can see here inside of the switch statement I'm saying in that case it means that in case
the value that is inside of the index zero of this array is number five which it is.
As you can see the value is.
Number five ok then increment the value of these 5 stars of The View valuable by one and then return
that value to me.
OK.
And that break out of this switch statement.
OK.
So here again I can just type in case four plus plus false starts review semi-colon rage case free plus
plus free review.
Break case two colon plus plus two starts review semicolon break case 1 colon plus plus one star review
semicolon break.
OK.
So now the result of this switch statement is actually the same as the result of this if statements
that you actually created here.
OK so now let's actually run our project again and let's see what happens.
So as you can see here our application is actually running on the emulator.
So let's actually click on this.
Show me the results button as you can see we can see these values again here.
OK.
So let's actually click on this button again as you can see these values don't change.
Our application is actually working right.
OK.
So hopefully that makes sense and I think that's enough for this tutorial.
If you have any questions please post the discussion in the course and 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.