Hello this is Martez or Curdy and it is really really going to actually make is it equal Potten work.
So just open your a calculator calculator job fine.
And here we have the uncle of it.
So if you go inside is switch statement.
We have this case are that ID that PTEN equal.
So now inside this case we are going to call.
Operator is tapped method.
And we're going to pass the the equal operator as the argument to this method.
So operator that you call.
So now that's enough.
OK.
Just calling this if it is enough in order to make a disobedient equal work because then this method
is called here the operator is tapped is called and are actually passing the equal operator to this
method.
First as you can see the current operator is not equal to not because the equal operator is actually
passed because or some operation has actually been executed.
So the current operator is not not.
And if it is not then it's not going to actually secure this if statement is it's going to actually
be assigned a current number to this street number at.
Right.
And then it's going to actually set the empty value to this current number variable.
And this switch statement is going to be executed.
So now let me show you the emulator here.
For example we have number five.
OK.
Number five multiplied by two.
OK.
And now I'm going to press on this equal button.
The result is going to be output to the console.
So here when I say this switch statement is going to be executed.
So first you can see that the current number is going to be assigned to this strange number.
That's right.
So here we have the number 10.
OK.
But now when the switch statement is going to be executed it is switching between the values of the
current operator.
When I say the current operator is that it doesn't mean that the current operator is actually equal
operator because at the end of this operator is that method we are going to update the value of this
current operator variable.
So at the end of the Smurfette here you can see in line number of 199 you are assigning the tapped operator
to the current operator.
So for example when I say 5 multiplied multiplied by two.
OK.
Now if I press on is equal button here it doesn't mean that now the current is equal but equal operator
is the current operator.
Is that just a tapped operator.
The current operator is that multiplication operator that I pressed before this equal operator.
So now here let's actually circle with.
Here it says.
So each count operator.
So it's going to switch between the values of the current operator in our case we said that.
So let me just explain again.
We said to multiply it by five.
In anti-state current operator is multiplication operator right.
So here it's going to actually take a look at this case statement case multiply and it's going on just
calculates the result at street number left multiplied by a string number that's right.
And the result is going to be assigned to these calculations the result variable.
Right.
And then it's going to go down here after this.
Any curly brace is going to update the value of this string number that's left by actually assigning
the calculation result to this variable.
And then the value is going to be displayed on the screen.
So test results that said text string number at left.
And finally we are actually updating the value of these calculations strange in order in order to show
this value to the user at the top here.
So now we can actually run the app and here you can see that after executing these lines of code here
this statement here is not going to be executed because the current operator is not equal to null.
If an operation is actually occurring and then the task of Rotary is going to be the current OPERATOR
OK.
So now we can actually run the app.
We can't say run and let me show you the emulator.
So for example if you have number five multiply by two here now I'm going to press on this this one
this call button.
Now the result is and with it here to the screen.
OK.
So now you can't I told you that the current operator is going to be the tapped OPERATOR Right.
OK.
So now I'm going to say number 10.
He had to resolve it multiplied by two equal operator and now our application is crashed.
So this means that there is a bug inside our application.
First of all it's in order to find the bug we need to take a look at the locks.
The first step is to take a look at the locks.
So at that point I'm going to click on this Lochhead here.
So let me show you the locks.
And here it says.
Let me actually show you here.
So now here we're going to take a look at the right texts.
Actually the it takes are going to show you are the exact park the fatal exception.
And here it says that there is a number format the exception for input screen empty screen.
Here you can see that here.
And we've got two links actually the first one is calculator file Java line.
If you click on it it's going to actually highlight the operator is tapped method calling him for the
speedy and equal case and the next one is actually the triangulated job.
One hundred and sixty.
The air is accurate here.
And you can see that this three numbers at lift.
Valuable is highlighted so there is something right here inside the arch of light.
So let me close at this last check here in order to find the bag.
We don't have to look through the codes in order to find the bag and kill it so that our application
works.
That's not how it is designed.
That's not how it works.
We've got debugging tools at our hands that we can use it in order to find the bug and solve it.
So how we can actually use these debugging tools.
So first of all we know that US there is something wrong with our sync number lift method or variable
actually.
So I'm going to create a debugging point of red point here for this operator is Taft's of Meffert.
So in line number of 148 here when I actually create this method uprated is that I'm going to create
our red point for this effect.
It is called a debugging point so that we can actually debug from this line of code.
And then we can actually step by step by step see what's wrong with our coats.
So now I'm going out run the app I'm going to.
So I'm not going to run the app.
We've got another option.
We've got debug the app.
You can see this one here a bug a great bug and you can see this play about it here on this great park.
So just click on this one unless he has an emulator and then click on it.
Let me show you the emulator.
So it's it's as is waiting for people here.
So let's wait now it is ready.
Now I have number five.
OK.
So I'm going to just click on number five multiplied.
So now the debulking is started.
So if you're going to step by step see what's wrong with our code and see exactly how to debug the app
now.
Team effort OPERATOR This is actually called because I clicked on this multiplication operator.
So that's why the debugging is now started because I created this red point for this method.
Operator Is that here we have some options some icons.
The first one says step over step over is going to execute the current code.
The current line of code in its entirety.
So we're going to execute that line of code in its entirety so that we can step over as you can see
it wanted to actually execute this line of code.
If current operator is not equal to no.
So the current operator is actually not all because of an I pressed on this multiplication operator
are the current operator is null.
We have a tapped OPERATOR So you can see that it's as the tag the operator is multiply.
But the current operator is not.
So this if statement here is not going to be executed.
So the flow of the program is going to go in so it is else that it isn't right and it's going to execute
this line of code.
It says string number at lift.
Assignment operator current number.
So we've got the current number which is number five.
And here you can see that here.
So it has a number that is not.
And you've got a kind of number which is number five.
So the number five is going to be assigned to the string number at left.
If I could kind of step over now this line of code is going to be executed and the number 5 is going
to be assigned to this number Atlas.
So let me click on it.
Now it's going to say that there's three numbers is number five.
And here we want to assign an empty string value to this column number valuable.
So it says that the current value of the current number value is 5 but then it this line of code here
is going to be executed of this line of code is executed the empty value the empty string value is going
to be assigned to this kind of number right.
So let me click on this over.
Now are we just see if they actually hover over this number here we can see that an empty string value
is a science that is valuable.
Now I was going to ask you this line of code the tap's operator is going to be assigned to the current.
OPERATOR OK.
So now the card operator is going to be the multiplication operator.
So if I show you the emulator and now if I click on this step over.
Now it says the current operator is multiply the top rated is also multiplied right.
So now is it reached to the end of this method.
Now if I click on that over again.
Now you can see that this line of cohered is executed the operator is tapped and you can see that it's
going to assign this value to this variable calculation string.
So there is not there is nothing wrong with our calculations or the calculations.
So if going to just resume the program.
So at the left hand side you can see these left sidebar of this debulking area.
It is a resume program.
So let's click on resume program.
So it might be five multiplied by for example 6.
Now I'm going to click on this equal.
Operator.
So again the operator is tapped.
Method is called.
OK.
So that it's going to again take a look at this if statement if current operator is not equal to not.
So the current operator is not equal to now because the current operator is the multiplication operator
and the current number is not equal to an empty stream.
Value.
So it says true the current number is not equal to actually an empty string value.
So it is true you can see that this value here because we press undersexed number sets.
So if I click on step over this if statement evaluates to true and is going to execute this if statement
is going to actually is the this line of code.
So the cost number is going to be assigned to district number.
That's right.
The current Nobody is number six.
So if I can step over we can see that it is screen number X-Rite is sex and about the current value
of the current number is 6.
Now we want to assign an interesting value to the kind of number.
So if I click on that over now it is the kind of number value is empty string.
So now going to execute the switch statement.
Let's get this step over.
So we know that the counter-protest is multiply so it's going to execute this case multiply.
And here we are going to actually you can see that it says our calculation result is zero the value
of this variable is zero and the string length is 5.
So let me kind of step over now.
It says now that we have five I think number three is six.
OK because we press on number 6.
So if I can step over now the calculations result is going to be the value of the calculation.
The result is going to be 50.
So let me show you that here's the number if these five calculation result is 50 so you want to assign
the value of the calculation results to the string number at left here.
So if you click on this step over this line of code is executed it says change relations result 40 and
it's going to secure this value.
So it's going to output the value of the string number at left of the screen.
And finally it's going to be the cutest line I've got here.
So and finally here after these these lines of code is going to assign the tapped operator to the current
operator so that half the operator is actually equal we can see that here the equal of right is going
to be assigned to this current operator.
So effectively conc that over again.
Now this line of code is executed the current operator is equal.
And now I'm going to click on the over again so you can see that this line of code here is actually
going to be executed equal.
And here because the operator restaffed and we said operator that equal and beep at Preston the equal
button.
So we're going to click on this over again.
And finally it's going to secure the line of code.
So there is nothing wrong with our takes the triangulation So if you're going to just resume the program
resume program by just clicking on the play button here inside this debugging area.
So not the number 50 here is out with it with this screen.
OK.
So now we have number 50 as the result.
Now I'm going to say 40 plus.
So here this is really important here.
It is where we actually find the park and just notice that here I am actually teaching you advanced
debugging in Android so make sure to pay attention to what I'm teaching you because this is very important
and it's going to help you a lot in your future Android projects.
If you are Android If you're actually an Android Developer and don't know how to debug an app you're
going to encounter lots of problems.
Trust me.
So now just up here tension here.
I actually press on the plus operator here.
Right.
So now at the affrightedly Statham if it is called Here we say if the current operator is not equal
to and also the current operator is equal.
OK.
Here you can see the value of the current operator.
So it is not equal to all.
And here it says and the current number is not equal to an empty stream given you.
So it's is true the kind of number is not equal to an empty string value.
Right.
And here I'm going to actually just click on step over so there is something wrong here OK.
There is something wrong here.
The current number is actually no it's not not.
It is actually the value of the kind of number it is an empty string value.
You can see that here canit number is not equal to an empty string value and it is true.
This means the current number is actually empty.
And that's why this statement here didn't execute and it the flow of the program went into the else
statement here.
OK.
So when I pressed on.
So we have the result 30 and I pressed on the plus operator.
Now it wants to execute the SQL statement.
So now if it wants to assign the current number which is actually an interesting value to this three
number I left.
So here you can see that it says that the value of the current number is empty.
It's just showing us the value of the current number.
So this empty value is going to be assigned to the string number.
Let's click on step over.
Now you can see that the value of this thing number at live is actually an empty string value and the
value of the current number is also an empty string value.
Right.
If I actually kind of step over again now the tapped operator is going to be assigned to the current
operator.
So the current operator is going to be Plus the plus operator.
So if I actually kind of step over is going to go on I can see that it's this case a statement between
the plus is executed.
So there is nothing wrong with this line of code so we're going to just resume the program.
So we have 40 plus and not is that now the value of the string number at lift is an empty string value.
And that's where the bug is so if I can for example number five and if I click on these equal operator
here here the app is going to crash.
But because we created a debugging point here a red point we can actually control the flow of the program.
So now I'm going to show you that the app is actually going to crash.
Now you know that we have that kind of operator is plus and the current number is five because I pressed
on the number five here.
OK.
So I'm going to ask you this if statement.
If I click on this here so let me show you that if I actually show you that.
Let's click on this.
Step over.
Now the value of the current number if it is actually number five is going to be assigned to the string
number.
And right so we have number five as the value of the string number.
That's right.
And we're going to execute this kind of number this line of code and an empty string value is going
to be assigned for the current number.
So let's kind of step over.
And now he's going to is a huge statement and the current operator is Plus if I click on this that over
again.
So this case statement here is going to be executed case plus calculations with the assignment operator
integers that parse and string number.
Absolutely if it's.
So if I hover over this string number at length it means it says that the value the current value of
this string number at left is an empty string value.
So we cannot convert an empty string value to an integer value.
So what happens when I click on this tip over our app crashed and if I click on a resume here you can
see that the application crashed.
So we found the park and now we need to solve that part.
So let me close this for let's little into this calculator that will file and here the problem is inside
this line of code this approach to restaffed method we need to create an initial statement for the kind
of number is not equal to gnarl is not equal to empty string value.
So by using an and logical operator at a park actually went inside our application.
So here we need to use an if statement instead of an and and logical operator.
Right.
So here we can go inside each statement and see if current number is not equal to an empty string value.
Then we can open and close this statement by using these curly braces and we can actually delete this
part of this if statement here.
And we don't want to use this as a logical operator.
So here we use an inner ears and in a if statement instead of an ontological operator.
So if we're going to actually delete does anything really break out of this if Karez number is not equal
to interesting value.
And if you're going to put the 88 in curly brace here before dispells a statement here OK.
So now this you can see that now dispells statement here is only related to this current number if current
operator is not equal to.
Now if statement not the inner one does one if the current number is not equal to an empty string value
OK.
So whenever this statement here is kind of operator is not equal to null.
If whenever this condition fails then the else statement here is going to be executed.
OK.
And if this condition here is kind of the number is not equal to an empty string value here if this
condition fails it's not going to execute the else statement because inside the else statement we are
actually assigning an empty string value to the current number.
OK so that's the cause of the error.
So now let me actually delete this a breaking point.
By just clicking on it.
And now if you run the app let me show you the emulator.
So for example we have number five multiplied by free equal to 15 plus free.
Now if I click on is equal here our application is not going to crash.
The result is going to be shown to the user number 18.
Now the error is solved.
OK.
If you want to.
So we can actually also create a breaking point here again for this operator is that.
So let's again click on this debugging here debulking and let me show you the emulator because I want
to show you now the bug is killed and we can actually run the app smoothly and see for example Number
five plus number five plus.
So he had his papped operator is plus and the current operator is null.
So this means that this if this condition here it evaluates to false this condition here fails.
And now it's going to execute the else statement.
If I click on this that over.
So you can see that the card somebody is going to be assigned to district number at left.
And here the current number the value of the currency nobody is going to be emptied.
Right.
So now it's going to assign the taps operator to the current operator.
The operator is Plus So if it is secure the sign of code.
Now the current operator is going to be plus.
So let me resume the app so five plus two equal.
So again the affrightedly Statham's if it is called So now it's going to again execute this brief statement.
So if current operator is not equal to not so now the current operator is the plus OPERATOR OK.
If I click on this it's over.
Now this condition evaluates to true and the current operator is not equal to.
So we have this condition if current number is not equal to an empty string value.
The number is not equal to an empty string value because I pressed on this number two.
So again if I had this condition here evaluates to true and it's not a fake.
So if I click on this is that over.
Now it's going to take you design I've got Charon's number is going to be assigned to this thing number
three right.
Valuable.
So it's this number right 30 is now null the value of this value business is now null but the value
of the current number is two.
So number two is going to be assigned to district number and right variable.
If I step over here you can see the value of this string number that's right to and an empty string
value is going to be assigned to this current number.
So if I click on this step over here now is going to execute the switch statement.
So I pressed on the plus OPERATOR Right the current operator is now a plus.
So if I click on step over so it's going to secure this case plus and it's going to just add the value
of the string number at left.
So you can see the value of this number at a fixed number of Y to the value of the street number and
right which is number two.
So the result is going to be assigned to the calculation result and it's going to actually execute this
line of code here.
So number ASLEF assignment operators think that the value of calculation is result the value of the
calculation result is numbers.
And so number seven is going to be assigned to the string number and left and execute this line of code.
And it is going out with this value to the screen.
So now it's going to execute this line of code that taps operator is going to be assigned to the current
operator.
The operator is the equal operator.
So now it's going to.
It's going to be assigned to the current operator.
If we execute this line of code so it is the current operator is equal let's resume the app.
So now you can see number seven here.
So now you have the number seven.
Number seven multiply it.
I just click on clicked on the multiplied operator.
So it is current operator is not equal to.
So it's not because the current operator is an equal operator.
So let's say this line of code now is going to execute this line.
But if current number is not equal to an empty string value it is to cut the value of the current number
is actually an empty string value.
So there is something wrong here.
This condition here is going to be failed.
If I execute this line of code now we can see that the statement here didn't execute because if it would
if the else statement did execute the empty string value of the current operator is going to be assigned
to this number that live and that's where the actual park would occur.
Now you can see that because these statements now didn't actually secured it's going to assign the trapped
operator to the current operator that have the approach top multiply OK.
I said that 7 multiplied the top of Rotary's multiply and the tapped operator is going to be assigned
to the current operator.
So if I can step over now we can see the current operators multiply so let's resume the 7 multiply by
2.
If you click on these are equal operator here.
Now again it's going to check this condition if current operator is not equal to not it's not the value
of the current operator is multiply.
OK.
So that over and here it is if current number is not equal to an empty string value it's not because
now the value of that number is number two.
I clicked on the number two I and this number two.
So the value of that kind of number is to step over.
And here it says current number is going to be assigned to the string number.
Right.
So number two is going to be assigned to this variable string number that's right and the value of the
kind of number is going to be emptied.
And so each kind of operator which is going to be a multiplication operator and it's going to stick
with this line of code the string number at left is seven and string number that's right is number two.
The result is going to be assigned to the calculation result number 14.
So here is going to as I assign the number 14 to this string number at live step over.
And the value is going to be outfitted to the screen.
So now the trapped operator which is actually the equal operator is now going to be assigned to this
current operator.
So is that over.
And now if I step over again.
So let's resume resumed.
And now we can see.
Let me show you the emulator so you can see that number 14 is output to the screen and our application
didn't crash.
So I can number 14.
So let me just with this breaking point aren't in order to show you that the bug is actually killed
and we can run the app smoothly without any error.
So five minus three equal number two four so multiplied by nine equals 18 divided by three equal six.
So you can see that that application works fine.
OK.
So that's enough for this tutorial.
And in the next story we're going to work on this clear pattern so that they never spot it is actually
tapped or clicked everything on the screen of this for example the text results that Tastee calculations
everything should be clear and the user and the user can actually start calculating from New.
So thank you very much for watching.
If you have any questions please support the discussion in the course and then I will do my best to
answer all of your questions.
I'll see you in the next tutorial.