1
00:00:01,680 --> 00:00:06,600
OK, this video, we want to start to work on this ad correct function, and this is the function that's

2
00:00:06,600 --> 00:00:11,760
going to get called, as you know, when we press the button and it will calculate whether or not the

3
00:00:11,760 --> 00:00:13,800
answer we typed into the box is correct or not.

4
00:00:13,830 --> 00:00:18,690
So the first thing we really need is to figure out what the correct answer actually is.

5
00:00:18,690 --> 00:00:18,990
Right.

6
00:00:19,350 --> 00:00:24,300
So let's let's go call you late.

7
00:00:24,870 --> 00:00:27,030
The actual answer.

8
00:00:27,780 --> 00:00:29,640
And that's going to be let's create a variable.

9
00:00:29,640 --> 00:00:30,780
Let's just call it correct.

10
00:00:31,140 --> 00:00:35,550
And that's going to be number one, plus number two.

11
00:00:35,880 --> 00:00:42,060
And that's just this number one in this number two, which we got from the button by passing in num

12
00:00:42,060 --> 00:00:46,080
underscore one douget and num underscore to get.

13
00:00:46,320 --> 00:00:51,690
And then when they come to this function we turn them into number one, number two, without an underscore

14
00:00:51,690 --> 00:00:55,560
just so that we can keep track of them better, we could probably call them number one and number two.

15
00:00:55,560 --> 00:00:59,730
But we want to fiddle with num num num num to underscore later on.

16
00:01:00,210 --> 00:01:02,360
So we'll just do it like this.

17
00:01:02,490 --> 00:01:04,580
So, OK, this is the actual correct answer.

18
00:01:04,860 --> 00:01:11,590
Now we need to create some logic to determine whether or not our answer is the correct answer.

19
00:01:12,270 --> 00:01:13,920
So let's go if.

20
00:01:15,000 --> 00:01:23,100
Add, underscore, answer doget, and we actually need to wrap this in an integer function to make sure

21
00:01:23,100 --> 00:01:26,490
that it's an integer and this ad answer, where am I getting that?

22
00:01:26,490 --> 00:01:30,240
That is our add enter entry box.

23
00:01:30,450 --> 00:01:32,370
This is whatever they typed into that box.

24
00:01:32,370 --> 00:01:32,650
Right.

25
00:01:32,970 --> 00:01:38,720
So if add in add answer doget equals double equal to sign.

26
00:01:38,730 --> 00:01:39,790
That's how we do a comparison.

27
00:01:39,810 --> 00:01:40,320
Operator.

28
00:01:41,550 --> 00:01:51,000
Correct, then let's just say correct for now, we'll fix this in a second or else incorrect.

29
00:01:51,340 --> 00:01:51,690
Right.

30
00:01:52,400 --> 00:01:55,650
OK, so now what do we want to put here in correct and incorrect?

31
00:01:55,680 --> 00:02:02,820
Well, we want to slap something up on the screen, at least for now, that says correct or incorrect.

32
00:02:02,820 --> 00:02:03,090
Right.

33
00:02:03,090 --> 00:02:14,250
So let's create a variable and let's do it up here and let's call this correct and incorrect message.

34
00:02:14,560 --> 00:02:14,970
Right.

35
00:02:15,330 --> 00:02:27,710
So I'm going to call this output answer, underscore, correct and output underscore answer incorrect.

36
00:02:27,720 --> 00:02:31,890
So we're going to create two variables, and I want to create these as string variables.

37
00:02:32,100 --> 00:02:36,450
So let's go string var and we can just copy this.

38
00:02:38,110 --> 00:02:41,970
OK, so their actual string of errors but now we want to set them.

39
00:02:41,980 --> 00:02:46,530
So let's go dot set.

40
00:02:47,830 --> 00:02:52,900
And then, boom, that set off this one needs to be incorrect.

41
00:02:53,660 --> 00:03:00,820
OK, so what do we want to set these as well for now, let's just say correct.

42
00:03:03,430 --> 00:03:11,290
And incorrect and, well, we'll snazzy this up a little bit in a bit, but for now we just want correct

43
00:03:11,290 --> 00:03:13,120
and incorrect and what do we want to do?

44
00:03:13,210 --> 00:03:18,250
Well, we want to put these in a label and I'll put it on the screen.

45
00:03:18,250 --> 00:03:20,230
So let's call this ad.

46
00:03:20,230 --> 00:03:21,820
Underscore, correct.

47
00:03:22,240 --> 00:03:23,470
Underscore a label.

48
00:03:26,940 --> 00:03:36,030
What I want to do is create this label outside of this function, and I'll show you why in just a second

49
00:03:36,450 --> 00:03:38,100
if we come down to our ad function.

50
00:03:38,110 --> 00:03:40,740
So here we have our answer box or whatever answer button.

51
00:03:41,100 --> 00:03:49,140
Here we have let's put another comment and say correct or incorrect message.

52
00:03:49,980 --> 00:03:51,270
And there it is.

53
00:03:51,280 --> 00:03:54,000
And actually, I want to make this global so it can be used all over the place.

54
00:03:54,030 --> 00:03:55,140
So let's call global.

55
00:03:56,310 --> 00:04:03,390
And now let's create this, it's a label, and we want this to be in our ad frame and we want the text

56
00:04:03,390 --> 00:04:05,190
to equal for now.

57
00:04:05,190 --> 00:04:09,990
Let's put into your answer above.

58
00:04:11,540 --> 00:04:14,540
Right, and then let's add correct.

59
00:04:15,600 --> 00:04:24,030
Underscore label, dot pack, and let's give this iPad pad Y of, I don't know, five, OK, let's just

60
00:04:24,030 --> 00:04:25,110
see here.

61
00:04:25,120 --> 00:04:26,370
That looks right.

62
00:04:27,440 --> 00:04:36,020
Now, if we come up here, we can update that and a bunch of videos ago that show you how to use pack,

63
00:04:36,020 --> 00:04:38,900
forget and forget, that's a way to hide things.

64
00:04:39,080 --> 00:04:43,790
You can also just update them using their configuration settings.

65
00:04:44,000 --> 00:04:46,880
And I think that's probably the better way to do it in this case.

66
00:04:47,040 --> 00:04:51,740
I didn't actually show you how to do that earlier, but I'll show you now we can just call ad correct

67
00:04:51,740 --> 00:04:57,350
label dot config and set the text equal to whatever we want.

68
00:04:57,380 --> 00:04:58,490
Well, what do we want to sell it to?

69
00:04:58,490 --> 00:05:00,980
Let's set it to this.

70
00:05:04,030 --> 00:05:08,410
But we want to get it, so get and we could do the same thing down here.

71
00:05:09,570 --> 00:05:17,130
But instead of output answer correct, we want to output answer incorrect so we can just paste that.

72
00:05:17,160 --> 00:05:20,850
OK, so let's save this and see if that worked.

73
00:05:20,890 --> 00:05:21,750
Let's run this guy.

74
00:05:22,330 --> 00:05:26,390
We got math flash cards and now we have this little message down here.

75
00:05:26,400 --> 00:05:29,420
This is your answer above so we can go four plus nine.

76
00:05:29,430 --> 00:05:32,430
That's 13 and nothing changed.

77
00:05:32,440 --> 00:05:36,330
So we got an error somewhere and answer is not defined.

78
00:05:36,370 --> 00:05:38,030
What did I forget to do?

79
00:05:38,580 --> 00:05:41,960
Line 20 and line forty nine.

80
00:05:42,780 --> 00:05:46,170
OK, so add answer dot get.

81
00:05:47,830 --> 00:05:50,720
Let's see, uh, here's our ad answer.

82
00:05:50,740 --> 00:05:57,760
This is the entry box we need to make this global so that it could be used anywhere in the programs.

83
00:05:57,790 --> 00:05:58,720
OK, let's save this.

84
00:05:58,720 --> 00:05:59,610
That should do the trick.

85
00:05:59,620 --> 00:06:02,730
Hopefully it's clear the screen and run it.

86
00:06:03,070 --> 00:06:05,350
OK, so add a zero plus nine.

87
00:06:05,350 --> 00:06:06,550
Alesco nine.

88
00:06:07,790 --> 00:06:11,050
Correct, and you see it updates right there for us.

89
00:06:14,600 --> 00:06:20,770
If we run this again, it's no good, let's try this again and let's do it for incorrect to make sure

90
00:06:20,770 --> 00:06:21,430
that worked.

91
00:06:22,330 --> 00:06:24,400
Seven plus five is forty three.

92
00:06:24,910 --> 00:06:25,600
Incorrect.

93
00:06:25,600 --> 00:06:27,460
So the logic now works.

94
00:06:27,580 --> 00:06:29,770
Our little message outputs correctly.

95
00:06:29,890 --> 00:06:31,090
This is not a great message.

96
00:06:31,090 --> 00:06:31,540
Correct.

97
00:06:31,540 --> 00:06:32,080
Incorrect.

98
00:06:32,200 --> 00:06:33,160
That doesn't tell us anything.

99
00:06:33,160 --> 00:06:34,390
We want to be more specific.

100
00:06:34,390 --> 00:06:36,180
Like incorrect.

101
00:06:36,190 --> 00:06:39,690
Seven plus five is twelve not forty three you idiot.

102
00:06:39,870 --> 00:06:45,400
Know some little message like that so that we can sort of keep track of what our answer was and what

103
00:06:45,400 --> 00:06:48,250
the question was, because this is going to update too.

104
00:06:48,280 --> 00:06:50,980
So we'll start to look at that in the next video.

105
00:06:51,190 --> 00:06:56,260
And we also need to do some more work here so that when we click this button, we get new numbers here

106
00:06:56,260 --> 00:06:58,330
and this gets deleted.

107
00:06:58,540 --> 00:07:00,640
So we'll start to look at those things in the next video.
