YouSub
Untitled

en English

Untitled English subtitles

0 downloads · 30 lines · added Dec 11, 2015

Report a problem
What's wrong?
Advertisement

English transcript

We covered the first two items in the last video.
Feel free to re-watch those if needed.
The task to experiment with the code was a little open ended, so
these are a couple of things that we tried.
There's no single correct answer for this one, though.
If I set the quantity to equal two times the quantity, then if I hit the plus
button, then it will double the number of coffee cups we have.
When I tried it on a device,
indeed it does double the number of coffees from two to four.
I can also use the variable name twice or as many times as I want
in the expression that will be evaluated to store as a value for quantity.
Let's run this to see what happens.
This is essentially three times quantity, so if the orignal quantity is
two, then when we hit the plus button, it should bump up to six cups of coffee.
Even though it doesn't make sense to update quantity so
many times within the method, I just added more lines of code so
that you could see what would happen.
First I run the app in debug mode, then I click on the Debug tab, and
I can trigger the breakpoint by clicking on the plus button.
First I see that the quantity variable has been initialized to two.
And then we take that quantity variable and double it and then add another two.
That makes six cups of coffee, which is the value down here for the variable.
If I click step over again,
we're going to take the current quantity value and add two.
Since the value was six before, six plus two equals eight.
Then I'm going to take the existing quantity,
which is eight, multiply it by three to get 24, and display that on screen.
If I click resume, then the screen updates to 24.
Now let's revert back to what we had before, so
it matches the rest of our code.

Need subtitles from another video?