-
Notifications
You must be signed in to change notification settings - Fork 0
/
savingsAccount.js
62 lines (48 loc) · 1.4 KB
/
savingsAccount.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
'use strict'
class SavingsAccount extends Account {
/** This constructor creates new saving account for the class SavingAccount
*
* @param number is the Account number (Saving account number )
* @param interest is the interest rate in percent (%)
*/
constructor(number, interest) {
super(number);
this._interest = interest;
}
/**
* This getter returns the current interest rate of the Saving Account
* @returns {interest} in percent
*/
getInterest() {
return this._interest;
}
/**
* this is a setter of the interest
* @param value
*/
setInterest(value) {
this._interest = value;
}
/**
* this function calculates the interest of the saving account and
* then deposits it
*/
addInterest() {
this.deposit(this._interest * this.getBalance() / 100);
}
/**
* formats account information and
* returns to the caller
* @returns {string}
*/
endOfMonth() {
return 'Interest added SavingsAccount: ' + this.getNumber() + ' ' + this.getInterest() +
': balance: ' + this.getBalance() + ' Interest: ' + this._interest * this.getBalance() / 100;
}
/**
* @returns {string} representation of this account
*/
toString() {
return "Saving Account " + this.getNumber() + ": balance " + this.getBalance();
}
}