forked from rishikasnehi/Money-Manager-Application
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoneyManager.cpp
More file actions
140 lines (123 loc) · 2.89 KB
/
MoneyManager.cpp
File metadata and controls
140 lines (123 loc) · 2.89 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#include <iostream>
#include <stdlib.h>
#include <sstream>
#include <string.h>
#include <vector>
#include "utils.h"
using namespace std;
class Transaction
{
public:
string date, note;
float amount;
Transaction(string tx_date, float tx_amt, string tx_note)
{
date = tx_date;
amount = tx_amt;
note = tx_note;
}
};
class MoneyManager
{
public:
int balance = 0;
vector<Transaction *> incomeTransactions;
vector<Transaction *> expenseTransactions;
void addExpense();
void addIncome();
void showTransaction();
void showBalance();
void runApplication();
int getType();
private:
int addIncomeCategory();
void addExpenseCategory();
};
void MoneyManager::addExpense()
{
string tx_date = getDate();
float tx_amount = getAmount();
string tx_note = getNote();
Transaction *transaction = new Transaction(tx_date, tx_amount, tx_note);
expenseTransactions.push_back(transaction);
balance -= tx_amount;
}
void MoneyManager::addIncome()
{
string tx_date = getDate();
float tx_amount = getAmount();
string tx_note = getNote();
Transaction *transaction = new Transaction(tx_date, tx_amount, tx_note);
incomeTransactions.push_back(transaction);
balance += tx_amount;
}
void MoneyManager::showTransaction()
{
cout << "Type"
<< "\tDate"
<< "\tAmount"
<< "\tNote" << endl;
for (auto transaction : incomeTransactions)
{
cout << "Credit"
<< "\t" << transaction->date << "\t" << transaction->amount << "\t" << transaction->note << endl;
}
for (auto transaction : expenseTransactions)
{
cout << "Debit"
<< "\t" << transaction->date << "\t" << transaction->amount << "\t" << transaction->note << endl;
}
}
void MoneyManager::showBalance()
{
cout << "Your current balance : " << balance << endl;
}
int MoneyManager::getType()
{
int typeChoice;
cout << "Select entry type : " << endl
<< "\t1. Income" << endl
<< "\t2. Expense" << endl
<< "\t3. Show recorded transaction" << endl
<< "\t4. Show balance" << endl
<< "\t5. To exit" << endl;
cin >> typeChoice;
return typeChoice;
}
void MoneyManager::addExpenseCategory()
{
}
int MoneyManager::addIncomeCategory()
{
}
void MoneyManager::runApplication()
{
cout << "Starting money manager application" << endl;
for (int i = 1; i < 10; i++)
{
int choice = getType();
switch (choice)
{
case 1:
addIncome();
break;
case 2:
addExpense();
break;
case 3:
showTransaction();
break;
case 4:
showBalance();
break;
case 5:
return;
}
}
cout << "Stopping the application" << endl;
}
int main()
{
MoneyManager mm;
mm.runApplication();
}