Hello this is or Corti.
And in this material we are going to create some instance variables and an inner insight or calculator
class.
So first let's create and you know inside this calculator class I'm going to type in private ENM.
So you already know that Iran is actually creating our own type.
For example we have the type integer we have we have a type text view or Potten.
But when you create an arena it means that we want to create our own custom type.
Right.
So I'm going to say probates in am and I can say name it as operator.
So I'm going to just make it capitalized.
Operator
And then I'm going to open and close this in and by using these curly braces so I'm going to provide
some values here for my you know the first one is going to be selected sruti emulator.
We have this up plus OPERATOR So I'm going to say plus comma we have this subtraction operator subtract
comma if we have multiply operators of multiply comma and finally we have this divide operator divide
and we also have this equal operator so equal.
So these are the values of our in our.
OPERATOR OK.
Now after this Inam I'm going to create some instance variables.
So here at the bottom here after these two takes you I'm going to create a comment here.
Instance variables instance of
so the first instance variable is going to be off tapes 3 and so private Stream current number and number
semicolon.
So let's create another instance of our evil private Stream.
And the name is going to be stream number at left semicolon and another instance variable private strange
strange number at right semicolon.
So what does this mean string number had left string number at right.
Let me show you the emulator.
So here for example we have their current number so I can actually have this number two.
This is going to be the current number.
Right.
And we created a variable or instance variable named as string number at left.
This means at the left side of the operator.
So when I say multiply it here as you can see we have to multiply.
So now the number two is at the left side of this operator.
So this is called string number left.
And then actually select another number for example Number Six Here is number 6 is going to be district
number.
Right.
The number at the right of the operator OK.
So to multiply by six.
Now when I press on equal what the result is going to be shown to the user.
So that's why we created the card number this three number at lift and the string number at right.
OK.
Let's also create an instance variable of our own type.
So private's and the name is going to be operator.
Operator
And there is another actually make mateys a type operator capitalized.
Is that I just want to make it more special.
OK because this is actually our own type if you want to you can just make this method only the first
letter capitalized and then the other letters to be lowercase.
But here I just wanted to make it more special because this is going to be the operator.
This is very important in our church related application.
So the type is operator and the name is going to be current.
Operator syndicalism let's also create an instance variable of that integer.
So private int and the name is going to be calculations
resolved semi-aquatic
now I am going to actually paste a method inside our calculator class.
This is going to be named as number is tapped.
So let me show you the emulator.
So whenever I let me click click on clear but never to use it actually taps on this button for example
Number 8 or number 9 you can see that the numbers are actually put beside each other number 5 free to
1.
This is going to be called the method that we're into right now.
So let's go inside this calculator class before the end in brace of this chapter a little class.
I'm going to paste this.
So here it is some of it private void number is tapped.
This method has a parameter that is of type integer and its name is tapped number.
So whenever the if you want to actually call the Smurfette we're going to also pass that number that
is tapped to this method.
So the name of the parameter is papped number inside the Smurfette.
We are going to actually initialize our variable current number.
OK.
So it is a current number assignment operator current number plus strange that value of tapped numbers
so we want to actually.
In other words we want to concatenate the current number that is tapped with the value that is a path
again.
So for example the emulator for example of we have number one that is tapped.
Right.
And when they use that actually again taps on this number five we can see that number one is concatenated
with the value number five the current number plus strange that value of.
So it is the string that value of is going to get the integer value and convert it to a string value
because we want to show it here.
So string to the value of tap number and then if you want to actually display this value on the screen
so we don't really want to say 60 results that said text current number.
So that's why you can see this value here.
Now let's go inside our uncreate method here first and after this set content you Meffert we are going
to initialize the current number variable here because as soon as the application runs the current number
variable is not initialized.
So an added value is not.
So if you're going to say current number assignment operator two coats.
So it just isn't an empty string value to discard it's number variable.
And for this call collations result we're going to also assign an initial value as zero.
So we call a display event the app runs these two variables is the value of these two variables is not
actually null the already initialized a default value.
This is valuable here.
So that's it.
Now we are going to actually call DMF that number is tapped from some of our case statements inside
this unclick method.
So the name of the method is number is that.
So this means that we need to call this method whenever.
Let me show the emulator Let me show you on that whenever a number is tapped.
Right.
Whenever number is that you're going to call number is tapped.
So we have a pretty servant here right.
Case are that are you that petty and separate.
So we're going to say that number is tapped.
The user actually has to have on the number seven so we're going to pass numbers seven to the Smurfette
tapped number number 7.
So we have BT and a second number is tapped number eight.
Number nine number is tapped 9.
So if you want to you can skip this part of the video but I'm going to type it here manually nobody
tapped.
Number four
number five numbers theft five.
And finally we have numbers zero.
Nobody is tapped.
Numbers zero.
OK so now let's let me scroll down here so you can see that we call it the results.
That set takes the current number so you want to display its value on the screen.
Let's run the app and let's see what happens.
Let me show you the emulator.
So now our app is running on the simulator.
Let's click on number four.
So here you can see Number four is displayed here number 5 6 2 3 0 9 8 7 again 4 1.
So everything works fine here.
OK.
So let's go back to our studio now of we need to create another method that is going to handle it when
we use it actually taps on the operator for example plus a D minus operator the multiplication operator
the device operator.
So I think that's enough for the situation and it's really really going to create another benefit to
handle the tapping and the operator.
Thank you very much for watching and I look forward to seeing you in the next tutorial.