1
00:00:00,390 --> 00:00:01,380
In the last lesson,

2
00:00:01,410 --> 00:00:06,330
we got our quiz app to start displaying the questions that we were getting from

3
00:00:06,360 --> 00:00:10,560
our API. This question I landed on is pretty interesting.

4
00:00:10,650 --> 00:00:13,200
Nintendo started out as a playing card manufacturer?

5
00:00:13,560 --> 00:00:16,500
And I would love to know if that's actually true or false.

6
00:00:17,070 --> 00:00:20,310
So I'd really like these buttons to work basically.

7
00:00:20,700 --> 00:00:22,560
If I click on one of these buttons,

8
00:00:22,620 --> 00:00:27,090
I want to be able to check my answer against the real answer that we got back

9
00:00:27,090 --> 00:00:31,230
from our API. So in this lesson, that's what we're going to get to work.

10
00:00:32,070 --> 00:00:34,020
So I want this to be a bit of a challenge for you.

11
00:00:34,560 --> 00:00:39,560
We know that we can add a command argument to our buttons so that it calls a

12
00:00:41,490 --> 00:00:46,170
particular method when it gets pressed. Now, when that method gets pressed,

13
00:00:46,620 --> 00:00:51,620
we want to go into our quiz brain and call this check answer.

14
00:00:52,530 --> 00:00:57,480
Now this check answer method expects a answer to check against.

15
00:00:57,840 --> 00:01:02,700
Have a think about how you might solve this and get this to work so that we can

16
00:01:02,700 --> 00:01:07,290
start printing out whether if we got the question right or the question

17
00:01:07,290 --> 00:01:10,860
wrong. Pause the video now, and try to complete this challenge.

18
00:01:10,910 --> 00:01:11,743
Go. 

19
00:01:15,950 --> 00:01:17,360
Okay. Here's the solution.

20
00:01:18,080 --> 00:01:23,080
The first thing I'm going to do is create a new method called true_pressed

21
00:01:26,930 --> 00:01:30,050
and also a method called a false_pressed.

22
00:01:31,430 --> 00:01:36,430
This true_pressed is obviously going to be the one that will be the command for

23
00:01:37,100 --> 00:01:40,820
this true button and it's going to be self.

24
00:01:40,820 --> 00:01:44,900
true_pressed because we're inside a class and we have to make sure that there's

25
00:01:44,900 --> 00:01:49,280
no parentheses at the end of it because we only want to trigger this method

26
00:01:49,580 --> 00:01:54,530
when the button actually detects a click. In a similar way,

27
00:01:54,530 --> 00:01:58,250
we're going to add a command to the false button and it's going to be

28
00:01:58,250 --> 00:02:02,360
self.false_pressed. And again, deleting the parenthesis.

29
00:02:02,840 --> 00:02:05,210
And now we can figure out what to do in here.

30
00:02:05,930 --> 00:02:10,190
We already have access to our quiz brain object in here

31
00:02:10,520 --> 00:02:13,700
which is saved under self.quiz.

32
00:02:14,210 --> 00:02:16,280
When either of these gets pressed,

33
00:02:16,400 --> 00:02:21,400
then we can simply tap into self.quiz and we can call the check_

34
00:02:22,190 --> 00:02:24,770
answer method that exists over there.

35
00:02:25,310 --> 00:02:29,090
And we can pass over true when true_pressed is called,

36
00:02:29,480 --> 00:02:31,880
and then when false_pressed is called

37
00:02:31,880 --> 00:02:32,713
...

38
00:02:34,760 --> 00:02:38,870
we'll pass in false. Now it's going to go into this check_answer,

39
00:02:38,930 --> 00:02:43,040
pass that answer in and it's going to print out whether if you got it right

40
00:02:43,220 --> 00:02:45,950
or whether if you got it wrong. So let's test that out.

41
00:02:46,400 --> 00:02:51,400
Let's run the code again and make sure that we don't make any silly typos like

42
00:02:52,400 --> 00:02:53,300
comand.

43
00:02:53,630 --> 00:02:54,463
Yeah.

44
00:02:56,330 --> 00:03:00,490
So let's run our app and see if can answer some questions.

45
00:03:01,450 --> 00:03:04,570
Gumbo is a stew that originated in Louisiana.

46
00:03:05,260 --> 00:03:06,760
I think that might be true.

47
00:03:08,590 --> 00:03:10,540
And when I click on the button,

48
00:03:10,570 --> 00:03:14,230
you can see in the console it's printed whether

49
00:03:14,230 --> 00:03:16,720
if I got it right or wrong. Now,

50
00:03:16,720 --> 00:03:21,720
while our code works and we can see whether we got it right or wrong in the

51
00:03:22,060 --> 00:03:24,790
console, that's not something the user will see.

52
00:03:24,790 --> 00:03:28,120
This is only something that's available to us as developers.

53
00:03:28,630 --> 00:03:31,330
So how can we give the user some feedback?

54
00:03:31,900 --> 00:03:33,970
That's what we'll figure out in the next lesson.

