-
Notifications
You must be signed in to change notification settings - Fork 2
/
account.cpp
118 lines (103 loc) · 2.3 KB
/
account.cpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#include <iostream>
#include <string>
#include "account.h"
using namespace std;
account::account()
{
double balance = 0;
double current_loan = 0;
int credit_score = 0;
double interest_rate = 0;
double loan_limit = 0;
}
// when a user has an account, it will be passed to this constructor so that we can associate their account
account::account(PersonalDetails user)
{
// currentUser = user;
double loan_limit = currentUser.getAnnualIncome() * 1.2;
}
void account::deposit(double amount)
{
balance = balance + amount;
cout << "You have deposited " << amount << " dollars. Your account balance now is " << balance << ".\n";
}
void account::withdraw(double amount)
{
balance = balance - amount;
cout << "You have withdrawn " << amount << " dollars. Your account balance now is " << balance << ".\n";
}
double account::get_balance()
{
return balance;
}
void account::set_credit_score()
{
int annual_income = currentUser.getAnnualIncome();
if (annual_income <= 40000 && annual_income > 0)
{
credit_score = 1;
}
else if (annual_income > 40000 && annual_income <= 80000)
{
credit_score = 2;
}
else if (annual_income > 80000)
{
credit_score = 3;
}
else
{
credit_score = 0;
}
}
int account::get_credit_score()
{
return credit_score;
}
void account::set_interest_rate()
{
switch (credit_score)
{
case 3:
interest_rate = 0.1;
break;
case 2:
interest_rate = 0.05;
break;
case 1:
interest_rate = 0.02;
break;
case 0:
interest_rate = 0;
break;
default:
interest_rate = 0;
break;
}
}
int account::get_interest_rate()
{
return interest_rate;
}
double account::get_current_loan()
{
return current_loan;
}
void account::pay_loan(double amount)
{
current_loan = current_loan - amount;
cout << "You have paid " << amount << " dollars loan. Your current loan now is " << current_loan << ".\n";
}
void account::make_loan(double amount)
{
current_loan = current_loan + amount;
balance += amount;
cout << "You have made " << amount << " dollars loan. Your current loan now is " << current_loan << ".\n";
}
double account::get_loan_limit()
{
return loan_limit;
}
account::~account()
{
}