1
00:00:01,020 --> 00:00:03,320
Hello this is or Corti.

2
00:00:03,480 --> 00:00:10,110
And in this material we are going to create some instance variables and an inner insight or calculator

3
00:00:10,110 --> 00:00:11,580
class.

4
00:00:11,580 --> 00:00:18,250
So first let's create and you know inside this calculator class I'm going to type in private ENM.

5
00:00:18,440 --> 00:00:23,780
So you already know that Iran is actually creating our own type.

6
00:00:23,870 --> 00:00:29,380
For example we have the type integer we have we have a type text view or Potten.

7
00:00:29,390 --> 00:00:34,780
But when you create an arena it means that we want to create our own custom type.

8
00:00:35,090 --> 00:00:35,710
Right.

9
00:00:35,720 --> 00:00:41,720
So I'm going to say probates in am and I can say name it as operator.

10
00:00:41,810 --> 00:00:46,180
So I'm going to just make it capitalized.

11
00:00:46,210 --> 00:00:46,900
Operator

12
00:00:52,070 --> 00:00:56,750
And then I'm going to open and close this in and by using these curly braces so I'm going to provide

13
00:00:56,870 --> 00:01:02,660
some values here for my you know the first one is going to be selected sruti emulator.

14
00:01:02,660 --> 00:01:13,420
We have this up plus OPERATOR So I'm going to say plus comma we have this subtraction operator subtract

15
00:01:14,500 --> 00:01:25,170
comma if we have multiply operators of multiply comma and finally we have this divide operator divide

16
00:01:28,120 --> 00:01:34,390
and we also have this equal operator so equal.

17
00:01:34,480 --> 00:01:36,320
So these are the values of our in our.

18
00:01:36,340 --> 00:01:37,900
OPERATOR OK.

19
00:01:38,170 --> 00:01:42,580
Now after this Inam I'm going to create some instance variables.

20
00:01:42,580 --> 00:01:49,540
So here at the bottom here after these two takes you I'm going to create a comment here.

21
00:01:50,410 --> 00:01:54,590
Instance variables instance of

22
00:01:57,690 --> 00:02:07,400
so the first instance variable is going to be off tapes 3 and so private Stream current number and number

23
00:02:07,400 --> 00:02:08,660
semicolon.

24
00:02:09,190 --> 00:02:13,050
So let's create another instance of our evil private Stream.

25
00:02:13,390 --> 00:02:22,570
And the name is going to be stream number at left semicolon and another instance variable private strange

26
00:02:23,770 --> 00:02:30,700
strange number at right semicolon.

27
00:02:30,930 --> 00:02:34,760
So what does this mean string number had left string number at right.

28
00:02:34,770 --> 00:02:37,140
Let me show you the emulator.

29
00:02:37,560 --> 00:02:43,380
So here for example we have their current number so I can actually have this number two.

30
00:02:43,380 --> 00:02:44,940
This is going to be the current number.

31
00:02:44,970 --> 00:02:45,630
Right.

32
00:02:46,020 --> 00:02:51,680
And we created a variable or instance variable named as string number at left.

33
00:02:51,690 --> 00:02:54,540
This means at the left side of the operator.

34
00:02:54,540 --> 00:02:59,600
So when I say multiply it here as you can see we have to multiply.

35
00:02:59,610 --> 00:03:04,020
So now the number two is at the left side of this operator.

36
00:03:04,020 --> 00:03:06,440
So this is called string number left.

37
00:03:06,720 --> 00:03:13,050
And then actually select another number for example Number Six Here is number 6 is going to be district

38
00:03:13,050 --> 00:03:13,570
number.

39
00:03:13,660 --> 00:03:14,380
Right.

40
00:03:14,460 --> 00:03:17,780
The number at the right of the operator OK.

41
00:03:17,910 --> 00:03:20,710
So to multiply by six.

42
00:03:20,820 --> 00:03:25,480
Now when I press on equal what the result is going to be shown to the user.

43
00:03:25,530 --> 00:03:31,700
So that's why we created the card number this three number at lift and the string number at right.

44
00:03:31,850 --> 00:03:32,420
OK.

45
00:03:34,200 --> 00:03:38,160
Let's also create an instance variable of our own type.

46
00:03:38,380 --> 00:03:42,690
So private's and the name is going to be operator.

47
00:03:42,840 --> 00:03:43,520
Operator

48
00:03:46,750 --> 00:03:54,120
And there is another actually make mateys a type operator capitalized.

49
00:03:54,340 --> 00:03:58,220
Is that I just want to make it more special.

50
00:03:58,450 --> 00:04:05,140
OK because this is actually our own type if you want to you can just make this method only the first

51
00:04:05,140 --> 00:04:10,570
letter capitalized and then the other letters to be lowercase.

52
00:04:10,720 --> 00:04:15,240
But here I just wanted to make it more special because this is going to be the operator.

53
00:04:15,250 --> 00:04:18,370
This is very important in our church related application.

54
00:04:18,640 --> 00:04:22,280
So the type is operator and the name is going to be current.

55
00:04:22,680 --> 00:04:31,780
Operator syndicalism let's also create an instance variable of that integer.

56
00:04:31,840 --> 00:04:35,270
So private int and the name is going to be calculations

57
00:04:37,990 --> 00:04:40,720
resolved semi-aquatic

58
00:04:43,610 --> 00:04:49,220
now I am going to actually paste a method inside our calculator class.

59
00:04:49,250 --> 00:04:53,010
This is going to be named as number is tapped.

60
00:04:53,030 --> 00:04:54,470
So let me show you the emulator.

61
00:04:54,530 --> 00:05:00,200
So whenever I let me click click on clear but never to use it actually taps on this button for example

62
00:05:00,200 --> 00:05:07,790
Number 8 or number 9 you can see that the numbers are actually put beside each other number 5 free to

63
00:05:07,910 --> 00:05:09,150
1.

64
00:05:09,240 --> 00:05:12,780
This is going to be called the method that we're into right now.

65
00:05:13,010 --> 00:05:18,340
So let's go inside this calculator class before the end in brace of this chapter a little class.

66
00:05:18,380 --> 00:05:19,380
I'm going to paste this.

67
00:05:19,450 --> 00:05:25,050
So here it is some of it private void number is tapped.

68
00:05:25,100 --> 00:05:30,100
This method has a parameter that is of type integer and its name is tapped number.

69
00:05:30,110 --> 00:05:35,240
So whenever the if you want to actually call the Smurfette we're going to also pass that number that

70
00:05:35,240 --> 00:05:37,210
is tapped to this method.

71
00:05:37,280 --> 00:05:41,980
So the name of the parameter is papped number inside the Smurfette.

72
00:05:42,200 --> 00:05:47,200
We are going to actually initialize our variable current number.

73
00:05:47,410 --> 00:05:47,900
OK.

74
00:05:48,230 --> 00:05:58,490
So it is a current number assignment operator current number plus strange that value of tapped numbers

75
00:05:58,490 --> 00:06:00,040
so we want to actually.

76
00:06:00,080 --> 00:06:07,220
In other words we want to concatenate the current number that is tapped with the value that is a path

77
00:06:07,280 --> 00:06:07,760
again.

78
00:06:07,760 --> 00:06:12,230
So for example the emulator for example of we have number one that is tapped.

79
00:06:12,260 --> 00:06:13,070
Right.

80
00:06:13,100 --> 00:06:19,130
And when they use that actually again taps on this number five we can see that number one is concatenated

81
00:06:19,130 --> 00:06:24,540
with the value number five the current number plus strange that value of.

82
00:06:24,540 --> 00:06:32,300
So it is the string that value of is going to get the integer value and convert it to a string value

83
00:06:32,480 --> 00:06:33,890
because we want to show it here.

84
00:06:34,100 --> 00:06:39,800
So string to the value of tap number and then if you want to actually display this value on the screen

85
00:06:39,800 --> 00:06:45,030
so we don't really want to say 60 results that said text current number.

86
00:06:45,050 --> 00:06:48,240
So that's why you can see this value here.

87
00:06:48,230 --> 00:06:59,930
Now let's go inside our uncreate method here first and after this set content you Meffert we are going

88
00:06:59,930 --> 00:07:08,000
to initialize the current number variable here because as soon as the application runs the current number

89
00:07:08,000 --> 00:07:09,810
variable is not initialized.

90
00:07:09,980 --> 00:07:11,700
So an added value is not.

91
00:07:11,720 --> 00:07:16,040
So if you're going to say current number assignment operator two coats.

92
00:07:16,070 --> 00:07:20,860
So it just isn't an empty string value to discard it's number variable.

93
00:07:21,020 --> 00:07:28,690
And for this call collations result we're going to also assign an initial value as zero.

94
00:07:28,850 --> 00:07:35,840
So we call a display event the app runs these two variables is the value of these two variables is not

95
00:07:35,840 --> 00:07:40,420
actually null the already initialized a default value.

96
00:07:40,450 --> 00:07:42,860
This is valuable here.

97
00:07:42,860 --> 00:07:43,570
So that's it.

98
00:07:43,580 --> 00:07:52,270
Now we are going to actually call DMF that number is tapped from some of our case statements inside

99
00:07:52,280 --> 00:07:54,300
this unclick method.

100
00:07:54,630 --> 00:07:58,940
So the name of the method is number is that.

101
00:07:58,940 --> 00:08:02,630
So this means that we need to call this method whenever.

102
00:08:02,690 --> 00:08:07,470
Let me show the emulator Let me show you on that whenever a number is tapped.

103
00:08:07,490 --> 00:08:07,850
Right.

104
00:08:07,870 --> 00:08:11,770
Whenever number is that you're going to call number is tapped.

105
00:08:11,810 --> 00:08:14,450
So we have a pretty servant here right.

106
00:08:14,450 --> 00:08:16,680
Case are that are you that petty and separate.

107
00:08:16,760 --> 00:08:19,300
So we're going to say that number is tapped.

108
00:08:19,580 --> 00:08:24,050
The user actually has to have on the number seven so we're going to pass numbers seven to the Smurfette

109
00:08:24,380 --> 00:08:26,060
tapped number number 7.

110
00:08:26,360 --> 00:08:31,310
So we have BT and a second number is tapped number eight.

111
00:08:31,410 --> 00:08:35,070
Number nine number is tapped 9.

112
00:08:35,550 --> 00:08:40,970
So if you want to you can skip this part of the video but I'm going to type it here manually nobody

113
00:08:41,050 --> 00:08:41,820
tapped.

114
00:08:42,140 --> 00:08:42,840
Number four

115
00:08:45,500 --> 00:09:10,050
number five numbers theft five.

116
00:09:10,200 --> 00:09:11,960
And finally we have numbers zero.

117
00:09:12,180 --> 00:09:13,260
Nobody is tapped.

118
00:09:13,260 --> 00:09:14,270
Numbers zero.

119
00:09:14,450 --> 00:09:23,150
OK so now let's let me scroll down here so you can see that we call it the results.

120
00:09:23,190 --> 00:09:26,580
That set takes the current number so you want to display its value on the screen.

121
00:09:26,760 --> 00:09:29,850
Let's run the app and let's see what happens.

122
00:09:29,880 --> 00:09:32,330
Let me show you the emulator.

123
00:09:32,420 --> 00:09:34,950
So now our app is running on the simulator.

124
00:09:35,090 --> 00:09:37,340
Let's click on number four.

125
00:09:37,400 --> 00:09:49,450
So here you can see Number four is displayed here number 5 6 2 3 0 9 8 7 again 4 1.

126
00:09:49,670 --> 00:09:51,720
So everything works fine here.

127
00:09:52,040 --> 00:09:52,590
OK.

128
00:09:52,730 --> 00:09:59,870
So let's go back to our studio now of we need to create another method that is going to handle it when

129
00:09:59,870 --> 00:10:06,440
we use it actually taps on the operator for example plus a D minus operator the multiplication operator

130
00:10:06,730 --> 00:10:08,160
the device operator.

131
00:10:08,240 --> 00:10:13,370
So I think that's enough for the situation and it's really really going to create another benefit to

132
00:10:13,370 --> 00:10:16,950
handle the tapping and the operator.

133
00:10:17,090 --> 00:10:21,860
Thank you very much for watching and I look forward to seeing you in the next tutorial.

