Alright so let's continue and let's work on the transfer 1
money to another account. So basically we want to create a 2
function that will receive an account. And we want to be able 3
to make a deposit on this account. So that shouldn't be 4
too complicated. We're going to create a new function that is 5
going to be transfer money. And we're going to send an 6
amount of money so it's going to be an amount number and we 7
want to target an account. So this will be a bank account. So 8
I forgot here to say that it returns a number and so 9
transfer money is not going to return anything. So transfer 10
money well we just need to make sure that we have enough money 11
before sending it to the account. But fortunately the 12
withdraw is already doing this check. So maybe what we 13
can just do is a widthdraw of this amount on our own account 14
and right after that we can just do a deposit of this 15
amount on the other account. And if for some reason I don't 16
have enough money this is going to throw an error and since I'm 17
not catching it this is going to crash and we won't go to the 18
deposit. So technically we're good with the transfer money to 19
another account and we have checked that the minimum 20
balance is enough before doing a withdraw or a transfer so 21
that's perfect. Now let's work on the mensual interest. So 22
first we have to store somewhere the percentage of 23
menstrual interest. So we are going to receive that from the 24
constructor so let's do this so we can go at the top here and 25
we can create another private interestRate that is going 26
to be a number and I will have an interest ceiling that will 27
be the maximum amount the interest rate is going to be 28
calculated on, so interest ceiling. And I'm going to 29
receive that from my constructor so interest rate 30
and interest ceiling and these are going to be numbers okay 31
and I'm going to receive that so interest rate 32
and interest ceiling. So basically we just want to have 33
a function that would be in charge of returning what should 34
be the mensual interest. So I'm going to create another 35
function here. And I'm going to call it get mensual 36
interests. So this is going to return a number and technically 37
it doesn't need any parameters because it's going to use only 38
what's inside our class. So the balance, the interest rate and 39
the interest setting. So first we have to check if the balance 40
is above the limit the interest ceiling limit so if this 41
balance is greater than this interest ceiling then we're 42
going to calculate the interest rate on the maximum on the 43
ceiling so we're going to return this dot interest 44
ceiling multiply by this.interest rate otherwise we're 45
under the interest ceiling so we're going to return this dot 46
balance multiply by this interest rate and we're good so 47
technically now as you can see an account expect both interest 48
rate and interest ceiling so for example here I could set it 49
to one percent and the ceiling to 50000 like this, and technically 50
we should be able to calculate I'm going to do that after now 51
technically so I'm going to open my console and I'm just to 52
console log account one. get mensual interest and let's 53
see Zero. Oh right because I don't have anymore money so I'm 54
just going to remove all of that for now So it should be 55
calculated on 40000 and 1% of 40000 is 400. That is true. So 56
it seems that the mensual interest function is working. 57
We're good. So technically this and this are good. And we have 58
even done the interest ceiling. Okay so in the next video we're 59
going to work on the favorites. So let's do that in the next 60
one.