1
00:00:00,420 --> 00:00:02,540
Hello this is mortars or Curdy.

2
00:00:02,670 --> 00:00:10,500
And in this material we're going to create an idea of function or Mfat named as operator is tapped so

3
00:00:10,500 --> 00:00:16,830
that whenever the user taps on the operator something happens you're going to see the results here.

4
00:00:17,160 --> 00:00:22,490
Let's go inside this head here later class and after the increase the price of this number is to have

5
00:00:22,500 --> 00:00:31,560
to function we're going to say private void and the name is going to be operator is that operator is

6
00:00:31,900 --> 00:00:35,670
typed and then put up or Apprentice's.

7
00:00:35,670 --> 00:00:42,720
So we are ready to create a parameter for this function because we want to pass the operator that is

8
00:00:42,720 --> 00:00:45,670
actually tapped to this function whenever.

9
00:00:46,050 --> 00:00:53,940
Each move it or any a function or a switch statement calls this function or method we are going to pass

10
00:00:54,000 --> 00:00:58,430
the operator that is papped to that this method.

11
00:00:58,530 --> 00:01:06,380
So are going to say operator and the name is going to be tapped operators tapped.

12
00:01:06,760 --> 00:01:15,090
Operator And we're going to open and close this method by using these curly braces and first of all

13
00:01:15,280 --> 00:01:20,340
if you are great you are going to create an if statement inside this operator is tapetum it.

14
00:01:20,340 --> 00:01:29,710
So we're going to say if current operator current operator is not equal to non.

15
00:01:29,810 --> 00:01:35,270
And then we're going to often enclose these statements by using these curly braces.

16
00:01:35,320 --> 00:01:38,050
There isn't that we created this if statement is that.

17
00:01:38,050 --> 00:01:45,010
So for example in the emulator for example there is nothing here and the user actually presses on this

18
00:01:45,190 --> 00:01:51,310
plus OPERATOR We don't want anything to happen because the current operator is not.

19
00:01:51,670 --> 00:01:58,630
OK so in that case we are creating an if statement we are saying that if the current operator is not

20
00:01:58,630 --> 00:02:07,370
non OK and we are going to create another if statement if we can actually create an and logical operator

21
00:02:07,370 --> 00:02:08,110
here so we have.

22
00:02:08,110 --> 00:02:19,240
If current operator is not equal to not an current number that number is not equal to an empty string.

23
00:02:19,470 --> 00:02:25,760
So this means that there is something there is a number on this screen on the text view.

24
00:02:25,980 --> 00:02:28,730
And we want to actually do some operation on it.

25
00:02:28,800 --> 00:02:34,350
So first we are saying that if the current operator is not equal to not and the current number is not

26
00:02:34,380 --> 00:02:40,330
equal to an empty string then we can go inside each statement and say strange number.

27
00:02:40,340 --> 00:02:47,800
That's right assignment operator current number current numbers semicolon.

28
00:02:47,830 --> 00:02:54,850
So here we are saying that the number is that is actually at the right hand side of the operator is

29
00:02:54,850 --> 00:02:59,240
going to be the kind of number so if you are assigning the column number to the string number that's

30
00:02:59,260 --> 00:02:59,510
right.

31
00:02:59,500 --> 00:03:02,200
So let me show you the emulator.

32
00:03:02,360 --> 00:03:05,950
So let me show you this calculator.

33
00:03:06,370 --> 00:03:08,170
And here for example we have number five.

34
00:03:08,170 --> 00:03:15,160
Number five is the current operator and we press and this multiplication operator and we press on the

35
00:03:15,160 --> 00:03:16,720
number six.

36
00:03:16,720 --> 00:03:19,020
So number six is the current operator right.

37
00:03:19,300 --> 00:03:21,490
And we also want this number six.

38
00:03:21,490 --> 00:03:27,210
There is actually at the right hand side of this the multiplication operator to be the current number.

39
00:03:27,520 --> 00:03:33,590
So you're saying the current number that is actually the number 6 it is the string number at.

40
00:03:33,620 --> 00:03:34,570
Right.

41
00:03:35,000 --> 00:03:35,450
OK.

42
00:03:35,470 --> 00:03:38,920
So that's why we are assigning the current number to this three number.

43
00:03:38,920 --> 00:03:39,310
That's right.

44
00:03:39,310 --> 00:03:43,060
Valuable because this is how it is actually implemented.

45
00:03:43,480 --> 00:03:46,630
A little unclear but and again let me show you let me explain again.

46
00:03:46,690 --> 00:03:47,820
We have numbers too.

47
00:03:47,860 --> 00:03:50,420
This is the number at left and it is also the kind of number.

48
00:03:50,680 --> 00:03:51,940
And we press on.

49
00:03:51,940 --> 00:03:54,190
For example the plus operator.

50
00:03:54,190 --> 00:03:57,020
Now I want to press on the number three.

51
00:03:57,070 --> 00:03:59,730
Number three is the current number right.

52
00:03:59,770 --> 00:04:07,070
So it is also going to be the number at the right hand side of the operator of the plus operator.

53
00:04:07,090 --> 00:04:12,700
So if you're saying that the current number to be to be assigned to this Thring number.

54
00:04:12,730 --> 00:04:13,550
Right.

55
00:04:13,800 --> 00:04:14,350
OK.

56
00:04:14,530 --> 00:04:16,290
So that's how it is implemented.

57
00:04:16,300 --> 00:04:21,190
So now that the current number is assigned to this thing number asteroid we are going to say Carne's

58
00:04:21,190 --> 00:04:24,480
number assignment operator two quotes.

59
00:04:24,930 --> 00:04:30,370
So now we're going to empty this current number valuable because the value of the current number is

60
00:04:30,370 --> 00:04:32,350
already assigned to the string number.

61
00:04:32,350 --> 00:04:32,800
That's right.

62
00:04:32,800 --> 00:04:33,560
Valuable.

63
00:04:33,610 --> 00:04:34,860
We don't need it anymore.

64
00:04:34,980 --> 00:04:39,580
We are going to we we're going to actually empty this valuable this current number variable so that

65
00:04:39,580 --> 00:04:42,120
we can actually do something else with it later.

66
00:04:42,130 --> 00:04:44,900
Let's go back to our function this method.

67
00:04:44,960 --> 00:04:46,690
Operator restaffed Meffert.

68
00:04:46,980 --> 00:04:57,030
Now to create a switch statement here in order to switch between the values of the current operator.

69
00:04:57,080 --> 00:04:59,050
So we're going to say switch.

70
00:04:59,780 --> 00:05:02,370
And here I want to just put current.

71
00:05:02,380 --> 00:05:04,600
Operator here kind of later.

72
00:05:04,700 --> 00:05:05,560
Open and close this.

73
00:05:05,570 --> 00:05:08,030
So is this meant by using these curly braces.

74
00:05:08,030 --> 00:05:14,720
So we already provided our limited values for the operator for the current operator because the current

75
00:05:14,720 --> 00:05:23,030
operator is of type operator that we created ourselves inside our class so we can say case and then

76
00:05:23,450 --> 00:05:25,760
we have the value plus case.

77
00:05:25,760 --> 00:05:30,950
If the current operator if the value of the current operator is Plus break.

78
00:05:31,590 --> 00:05:34,370
So let me show you the emulator we have.

79
00:05:34,530 --> 00:05:35,880
Let me.

80
00:05:36,920 --> 00:05:40,870
We have this subtract operator case.

81
00:05:40,950 --> 00:05:43,740
If the value of the current operator is subtract

82
00:05:46,350 --> 00:05:54,210
call it break and if the value of the current operator is for example multiplication operators so case

83
00:05:56,400 --> 00:05:59,930
multiply break.

84
00:06:00,730 --> 00:06:09,320
And we have this why the divide operator chase the right break.

85
00:06:09,440 --> 00:06:14,210
And finally we have this equal operator so here we see a case

86
00:06:18,360 --> 00:06:18,960
case

87
00:06:21,640 --> 00:06:26,290
equal colon break.

88
00:06:26,620 --> 00:06:27,380
OK.

89
00:06:27,680 --> 00:06:33,750
So now for now I don't want you to just think about this equal operator and how these functions.

90
00:06:33,830 --> 00:06:35,630
This actually did it in this case equal.

91
00:06:35,640 --> 00:06:38,570
And for now I'm going to talk more about this later.

92
00:06:38,570 --> 00:06:45,690
For now let's just focus on the main operators the plus operator subtract multiply and divide operators.

93
00:06:45,710 --> 00:06:48,200
So now what happens when they use their taps.

94
00:06:48,200 --> 00:06:57,670
On the plus operator Let's see the created of a variable of type integer named as calculations resolved.

95
00:06:57,730 --> 00:06:59,960
It is of typing teacher assignment operator.

96
00:07:00,030 --> 00:07:09,070
So if we're going to say in teacher the class teacher that parse in and we need to pass a string value

97
00:07:09,070 --> 00:07:13,250
to this method parse it in order to convert it to an integer value.

98
00:07:13,390 --> 00:07:17,920
So if we have three number that's left plus.

99
00:07:17,920 --> 00:07:28,240
So let me create an inline integer integer that parse the pars and string number at.

100
00:07:28,310 --> 00:07:29,580
Right.

101
00:07:29,650 --> 00:07:35,660
You're going to add the value of the string number at lift to the value that is actually at the right

102
00:07:35,660 --> 00:07:41,480
hand side of the operator string number at right and the result is going to be assigned to these calculations

103
00:07:41,780 --> 00:07:45,180
result variable h.

104
00:07:45,190 --> 00:07:46,630
We have this break statement now.

105
00:07:46,660 --> 00:07:48,410
Let's see what happens.

106
00:07:48,480 --> 00:07:54,580
And to use a pass on the subtract operator here we are going to see calculations result.

107
00:07:54,910 --> 00:08:02,310
Assignment operator in teacher and teacher but parts in it.

108
00:08:02,500 --> 00:08:09,810
String number lift's string Ratliffe minus integer the parse and

109
00:08:13,740 --> 00:08:16,310
integer that parse gained string number.

110
00:08:16,310 --> 00:08:16,920
That's right.

111
00:08:16,920 --> 00:08:21,710
So three numbered right semicolon.

112
00:08:21,840 --> 00:08:22,770
So break.

113
00:08:22,920 --> 00:08:26,780
Now let's see what happens when the user taps on the multiplication operator.

114
00:08:26,940 --> 00:08:29,140
So again tabulation is resolved.

115
00:08:29,640 --> 00:08:32,230
Assignment operator teacher.

116
00:08:32,480 --> 00:08:38,210
That part's amed three numbers.

117
00:08:38,270 --> 00:08:41,980
Lift multiply.

118
00:08:43,410 --> 00:08:49,030
Buy in teacher that parts end string number.

119
00:08:49,030 --> 00:08:49,840
That's right.

120
00:08:50,990 --> 00:08:51,950
Semicolon.

121
00:08:52,100 --> 00:08:57,130
And finally we have this device OPERATOR So the calculation is resolved.

122
00:08:57,230 --> 00:09:04,260
Assignment operator integer that parse ain't string number.

123
00:09:04,330 --> 00:09:15,620
Lift divided by integer the parts in string number.

124
00:09:15,650 --> 00:09:16,300
That's right.

125
00:09:16,310 --> 00:09:18,660
String number three semicolon.

126
00:09:18,710 --> 00:09:26,510
So now after the ending curly brace of this sweet statement here I'm going to say that string number

127
00:09:26,510 --> 00:09:29,660
at lift strange number adds lift.

128
00:09:29,660 --> 00:09:40,830
Assignment operator streambed dot value of calculations result calculations result semicolon.

129
00:09:41,100 --> 00:09:47,140
So if you were to convert the calculations result to a string value and we're going to assign it to

130
00:09:47,140 --> 00:09:49,360
this three number at left roudy able.

131
00:09:49,500 --> 00:09:50,070
Why.

132
00:09:50,110 --> 00:09:50,800
Let me show you why.

133
00:09:50,800 --> 00:09:53,290
Let me show you the emulator.

134
00:09:53,290 --> 00:09:55,960
So now here it is our emulator right.

135
00:09:55,960 --> 00:09:59,020
And here for example we have number five.

136
00:09:59,230 --> 00:10:02,040
Number five multiplied by two.

137
00:10:02,470 --> 00:10:03,130
OK.

138
00:10:03,280 --> 00:10:14,250
And now I am going to for example say plus as you can see the multiply the number five multiplied by

139
00:10:14,250 --> 00:10:16,080
two the result is 10 right.

140
00:10:16,080 --> 00:10:20,400
So we have number 10 here and here you can see it at.

141
00:10:20,460 --> 00:10:23,960
Take a look at these takes you here at the top it is 10 plus.

142
00:10:23,970 --> 00:10:27,110
When he said Number Five multiplied by two.

143
00:10:27,120 --> 00:10:30,440
I didn't present this equal in here.

144
00:10:30,480 --> 00:10:32,560
I pressed on this plus.

145
00:10:32,570 --> 00:10:33,990
Operator.

146
00:10:33,990 --> 00:10:41,550
So the number five multiplied by two operation is executed and the result which is going to be number

147
00:10:41,550 --> 00:10:45,590
10 is assigned to this three number that's left Raddy bet.

148
00:10:45,620 --> 00:10:50,550
Now the result which is is number 10 is at the left hand side of this plus.

149
00:10:50,550 --> 00:10:57,810
Operator OK now number 10 is string number at left and that's why you can see here we assigned these

150
00:10:57,810 --> 00:11:02,460
calculations result to this string number at left variable.

151
00:11:02,840 --> 00:11:03,080
OK.

152
00:11:03,090 --> 00:11:06,920
Now it says 10 plus because we pressed on the plus operator.

153
00:11:07,320 --> 00:11:08,350
So now.

154
00:11:08,400 --> 00:11:11,290
So it is actually a little bit confusing.

155
00:11:11,310 --> 00:11:12,290
That's OK.

156
00:11:12,600 --> 00:11:19,050
But if you don't or do not understand it please make sure to watch this part of the video over and over

157
00:11:19,110 --> 00:11:22,080
again so that it completely makes sense.

158
00:11:22,080 --> 00:11:27,300
So after all this line of code here I can say 60 results.

159
00:11:27,510 --> 00:11:36,440
That said text string number at left street number that's left because now this three number at left

160
00:11:36,440 --> 00:11:41,720
is the result and that's why you can see here the number 10 is going to be district number at left is

161
00:11:41,720 --> 00:11:45,320
the result here we are going to display this value to the user.

162
00:11:45,650 --> 00:11:46,140
OK.

163
00:11:46,370 --> 00:11:54,860
So so now what happens if this if statements that we created here face this if current approach is not

164
00:11:54,860 --> 00:12:02,030
equal to know what happens if the current operator is not X is actually not ok.

165
00:12:02,210 --> 00:12:06,540
If the current operator is null then something else should happen.

166
00:12:06,740 --> 00:12:12,210
This if statement is not going to be executed if the current operator is actually not.

167
00:12:12,680 --> 00:12:17,080
So in that case you're going to create an if statement here.

168
00:12:17,200 --> 00:12:20,590
It is really based on your statement you can see that here.

169
00:12:20,960 --> 00:12:27,150
So when I click on this the curly braces can assure me that viridis anything really bright curly brace

170
00:12:27,150 --> 00:12:28,250
blanks to.

171
00:12:28,400 --> 00:12:35,030
So after this ending really brace I'm going to say it's ill's means that if this above part of the quote

172
00:12:35,030 --> 00:12:42,600
is if this part of the code if counter-protests is actually null then we're going to execute this.

173
00:12:42,600 --> 00:12:51,280
Else statement we're going to say that three number at liff is actually the current number.

174
00:12:51,290 --> 00:12:57,090
Semicon So if the user presses on a number the current number is going to be assigned to the string

175
00:12:57,120 --> 00:12:58,890
number at left valuable.

176
00:12:59,010 --> 00:12:59,340
OK.

177
00:12:59,370 --> 00:13:01,420
If the current operator is actually null.

178
00:13:01,650 --> 00:13:04,090
If there is nothing on the screen let me show you the emulator.

179
00:13:04,320 --> 00:13:06,640
Let me click on this clear.

180
00:13:06,660 --> 00:13:08,990
So now the current operator is knol.

181
00:13:09,120 --> 00:13:09,730
OK.

182
00:13:09,810 --> 00:13:12,960
And then I press on this number for example number five.

183
00:13:12,960 --> 00:13:18,870
Number five is the current number the kind of number is now going to be this three but live is going

184
00:13:18,870 --> 00:13:21,500
to be assigned to this number at left value.

185
00:13:21,950 --> 00:13:22,890
OK.

186
00:13:23,340 --> 00:13:30,250
And you're going to say current number assignment operator two code so that it is now completely emptied.

187
00:13:30,270 --> 00:13:31,960
And then we can actually use it later.

188
00:13:32,310 --> 00:13:39,330
And here after this statement here we can see that this is the curly brace of our Meffert operator is

189
00:13:39,330 --> 00:13:46,340
that we're going to say that the current operator is going to be the tapped operator.

190
00:13:46,480 --> 00:13:47,060
So we call.

191
00:13:47,130 --> 00:13:51,960
So now at the end of the Meffert you're going to say that the tapped operator is going to be assigned

192
00:13:51,960 --> 00:13:57,000
to the current operator whether it is if statement here or this statement is executed.

193
00:13:57,000 --> 00:14:03,120
It doesn't really matter when the function operator is tapped is called The tapped operator is going

194
00:14:03,120 --> 00:14:07,380
to be the current operator it is going to be assigned to the current operator.

195
00:14:07,560 --> 00:14:14,750
So for example let me show you the emulator we have number four multiplied by three.

196
00:14:15,080 --> 00:14:15,690
OK.

197
00:14:16,720 --> 00:14:21,200
And I'm going to say that plus.

198
00:14:21,530 --> 00:14:30,060
So now the plus operator is going to be the current operator von multiplied.

199
00:14:30,090 --> 00:14:36,020
So now we can see that the multiplied multiplication operator is now going to be the current operator.

200
00:14:36,150 --> 00:14:41,840
So that's why we put this line of code here in order to specify what is going to be the current operator.

201
00:14:41,850 --> 00:14:48,150
Every time the user presses on the specific operator on our calculator application.

202
00:14:48,150 --> 00:14:53,790
So now our function our operator is that function is complete.

203
00:14:53,790 --> 00:14:57,330
Now we need to call this function from somewhere else.

204
00:14:57,510 --> 00:15:03,830
And you know we want to actually call it we want to call it from that is that these case statements

205
00:15:04,290 --> 00:15:06,560
and we have some operators here.

206
00:15:06,570 --> 00:15:15,340
So for example case or ID that BT and plus right we are going to say operator is tapped.

207
00:15:15,660 --> 00:15:17,970
So what is the top now we need to pass the operator.

208
00:15:17,970 --> 00:15:20,440
We already know that BT and plus is tapped.

209
00:15:20,490 --> 00:15:27,690
So if are going to say OPERATOR You're going to refer to our in on call that we created this type darte

210
00:15:28,470 --> 00:15:32,080
plus Okay.

211
00:15:32,380 --> 00:15:36,200
And we also have to subtract operator.

212
00:15:36,310 --> 00:15:41,510
So case our that that BT and said right you're going to say operator is tapped.

213
00:15:41,710 --> 00:15:46,800
So I think there is a typo in the name of our income.

214
00:15:46,870 --> 00:15:48,110
So let me scroll to the top.

215
00:15:48,130 --> 00:15:50,840
You can see that yes there is a typo here.

216
00:15:50,890 --> 00:15:57,710
Operator So here we need to change the type our instance variable the type of this current operator

217
00:15:57,710 --> 00:16:06,730
to OPERATOR We need to actually delete this type here and scroll down here.

218
00:16:06,740 --> 00:16:12,600
We also need to choose the right name for this operator here.

219
00:16:13,520 --> 00:16:21,100
And for this SBT and subtract we're going to say operator that Cyp tracked this school down here so

220
00:16:21,100 --> 00:16:27,420
here for this for the name of the parameter of this operator is tap function Vinita right.

221
00:16:27,450 --> 00:16:30,670
We need to write the right name of right.

222
00:16:30,680 --> 00:16:36,360
So now the problem is solved with scrotal it up here you can see that for this PTM Plus we called operators

223
00:16:36,380 --> 00:16:41,140
tappet operator plus and for the speedy and subtract operator that set.

224
00:16:41,180 --> 00:16:42,110
Right.

225
00:16:42,290 --> 00:16:45,450
And we also have these PTEN multiply.

226
00:16:45,650 --> 00:16:47,800
So we're going to see operator is tapped

227
00:16:50,300 --> 00:16:53,600
operator is tapped.

228
00:16:54,140 --> 00:17:00,740
And we're going to say operator that Monte play.

229
00:17:00,860 --> 00:17:06,490
And finally we have this PTEN divide operators tapped

230
00:17:08,910 --> 00:17:17,570
operator dot divide so that sits.

231
00:17:17,630 --> 00:17:21,980
So now it's time to run our application.

232
00:17:22,010 --> 00:17:26,570
Let me show you the emulator.

233
00:17:26,690 --> 00:17:36,510
So here for example we have number five multiplied by number of free and let me click on this number.

234
00:17:36,540 --> 00:17:37,860
This plus operator.

235
00:17:37,960 --> 00:17:42,090
So now you can see the result here number five multiplied by three is 15.

236
00:17:42,400 --> 00:17:47,590
And we clicked on this A-plus operator plus free minus.

237
00:17:47,770 --> 00:17:55,130
So 18 15 plus free is 18 and we clicked on this minus operator 1 divided by.

238
00:17:55,150 --> 00:17:57,400
So here we can see this is number 17 here.

239
00:17:57,400 --> 00:17:58,720
So it works fine.

240
00:17:58,720 --> 00:17:59,890
It works perfect.

241
00:17:59,950 --> 00:18:06,240
So now we're going to do something so that the text we hear at the top is going to show some calculations

242
00:18:06,250 --> 00:18:15,370
that actually occur here so that we can see what number is multiplied with another number and how the

243
00:18:15,370 --> 00:18:16,970
calculations worked.

244
00:18:17,050 --> 00:18:19,360
So we're going to do that in the next story.

245
00:18:19,390 --> 00:18:20,920
Thank you very much for watching.

246
00:18:21,160 --> 00:18:26,590
And if you have any questions please sponsor a discussion in of course and I'll do my best to answer

247
00:18:26,590 --> 00:18:30,310
all of your questions and I'll see you in the next tutorial.

