Instructor: In this lecture
we're going to start with updating the income percentages,
which is the main task for this step three
of our project.
And this will be more of a short lecture,
and so we're just going to reinforce some of the concepts
and techniques that we have learned so far.
So here we are once again
in our app controller.
Now the question that we should ask is
when will these income percentages
actually be updated,
and the answer is that these percentages
are calculated and updated each time that we add
or delete an item,
because remember these percentages
are the percentage of the income
that each expense represents.
So when we add a new income
or when we delete an income from the list
then all of these expense percentages
will be updated, they will all change,
and also when we add a new expense
the percentage must be calculated
and of course updated and displayed.
So again when we add and when we delete an item,
and this means that we should probably
create a new separate function for this
so that we can then call that function
here in our control at item function
or control delete item function.
Okay so this is something very similar
to the update budget function here, right.
So we also created a function for that,
a separate function here
which is called update budget, and then called it
in both of these control functions here, right.
And so now we're going to do something similar
and I'm going to call it
update percentages, simply.
Update percentages.
And we don't need any arguments here,
and that's it.
All right and what are we going to do
here in this function?
And again it's very similar
to the update budget function.
So we first need to calculate the percentages.
Then after that we're going to read them
from the budget controller.
So very similar again.
And finally
we then update the user interface
with the new percentages,
and we're going to do that such as we did before
over the next two lectures.
So in the next lecture
we're going to take care of the budget controller
and then code these two functions here
to calculate and to get,
so similar to calculating
the budget and then getting the budget
and then finally we're going to code a method
which will then display these percentages
on the user interface,
but for now all we need to do
is to call this function here
in our other two functions, right.
So in here we have a step six,
which is to calculate and update the percentages,
and update percentages.
And this one is called update percentages.
So we call this function from here
so that we don't have to write the exact same code
down here in the function that handles
the deleting of an item.
Okay and calculate and update percentages,
and in here it's just step number four.
All right so in the next lecture
we're going to take care of coding these two methods
into our budget controller.