So let's return to the main activity, Java, to complete the application.
So now we should create a question object from the questions class.
And we can find the answer.
The score of the user.
I will update the questions depending on the length of the questions, so I'll create the integer that
will keep the length of the questions.
Let's create a variable to randomly update the questions with the random class.
And as you can see, it's imported here.
Now, to update the questions I would call the method here and.
I also need to create a method for this.
So that's created here.
You can set the text to be displayed in the text view, either when declaring it in your layout file
or by using its set text method.
So I said the text for all answers and questions.
OK, so I guess here now I missed something, yes, here I should have created a new random instance.
OK, great, so let's.
Yeah, let's complete the listener method's.
So we must write a conditional statement here to check the correctness of the answer, and if the answer
is true, the score must be increased.
If the answer is false, then we need a method to finish the game, so we'll create the last method
game over for that purpose.
So when the game is over, an alert will appear thanks to the alert dialogue builder.
And we'll set a message for this alert that will also display this score.
So let's say there's going to be two options on this alert dialogue, we'll create a positive button
for the user who wants to continue the game.
The dialogue interface on Click Listener.
Is used to allow the creator of a dialogue to run some code when an item on the dialogue is clicked.
And the star activity method starts in the instance of the display message activity that specified by
the intent.
So next, we'll need to create the intent.
The intent represents an app's intent to do something right, so get application context will return
the context for the entire application.
And if the game is over and the user may want to exit.
Well said a negative button for this, and it will finish the game and exit.
And then finally, we need to create an alert dialog object and call it with a show method to display
the screen.
So now let's complete all the methods for each answer.
Just copy this part and paste for every method of the answers, and don't forget to change the number,
the answers.
All right, so actually, it's a very simple project, but the project is complete now.
But before running the app, you should select the emulator that you created before.
All right, so let's start, Dhiab.
And our Android studio is installing the app on the video and see how it starts the emulator.
All right, so let's try out the game.
Well, look at that, it's working as expected.
But I'll tell you, let's delete the hard coded text view that's displayed first before getting the
score.
So to do that, I don't want to go to the design section.
Delete the default text for the score.
And let's run the app again.
All right, great, now you can, of course, change the UI for a much better view or extend the capabilities
of the app if you want to, but this is what we're going to use here to for.