Bank System
account.h
Go to the documentation of this file.
1#ifndef account_h
2#define account_h
3
4#include <cmath>
5#include "date.h"
6#include <algorithm>
7#include <vector>
8#include <map>
9#include <QString>
10#include <QTextEdit>
11#include <QTableWidget>
12
13// 累加器类
15{
16 // 上次操作日期
18 // 操作数额
19 double value;
20 // 和
21 double sum;
22
23public:
24 // 累加器构造函数
25 Accumulator(Date m_lastDate, double m_value);
27 // 求和
28 double getSum(Date m_date);
29 // 数值刷新函数
30 void change(Date m_lastDate, double m_value);
31 // 数值重置函数
32 void reset(Date m_lastDate, double m_value);
33
34
35
36};
37
38
39// 账目记录类
41{
42 // 日期
44 // 账户
45 string* id;
46 // 交易数额
47 double amount;
48 // 账户余额
49 double balance;
50 // 详细信息
51 string desc;
52
53public:
54 // 构造函数
55 AccountRecord(Date m_date, string* m_id, double m_amount, double m_balance, string m_desc);
57
58 // Info Printer
59 void show();
60
61 // getAmount
62 double getAmount();
63
64 // getID
65 string* getID();
66
67 // get Info
68 QString getInfo();
69};
70
71// 用户类基类
73{
74 // 用户ID
75 string id;
76 // 用户余额
77 double balance;
78 // 系统总存款
79 static double total;
80
81
82
83
84public:
85 // 账目记录
86 /*static*/ multimap<Date, AccountRecord>recordMap;
87 // Card Exist
88 bool has_savings=false;
89 bool has_credit=false;
90
91 // 构造函数
92 Account(Date m_date,string m_id);
93
94 //
95 virtual ~Account();
96
97 // 账户变动记录辅助函数
98 void record(Date m_date, double m_amount,string m_desc);
99 // 获取用户ID
100 string getID();
101 string* getIDPtr();
102 // 获取用户余额
103 double getBalance();
104 // 获取系统总存款
105 static double getTotal();
106 // get Rate
107 virtual double getRate()=0;
108 // get Credit
109 virtual double getCredit()=0;
110 // 打印用户信息函数
111 virtual void show()=0;
112 // 存款函数
113 virtual void deposit(Date m_date, double m_amount, string m_desc )=0;
114 // 取款函数
115 virtual void withdraw(Date m_date, double m_amount, string m_desc )=0;
116 // 结算利息函数
117 virtual void settle(Date date)=0;
118 // 历史流水查询
119 /*static*/void query(Date begin_date, Date end_date);
120 // show query result
121 void queryGUI(QDate query_date,multimap<Date,QString> &date_append_temp,multimap<double,QString> &balance_append_temp);
122 // Current Month Query
123 virtual double getCurMonthBillAmount(Date m_date,string m_bill_kind,string* m_id)=0;
124
125};
126
127
128// 储蓄卡类
129class SavingsAccount:virtual public Account
130{
131 // 累加器
133 // 利率
134 double rate;
135
136public:
137 // 储蓄卡类构造函数
138 SavingsAccount(Date m_date, string m_id, double m_rate);
139 // 获取利率
140 double getRate();
141 // 存款函数
142 void deposit(Date m_date, double m_amount,string m_detail);
143 // 取款函数
144 void withdraw(Date m_date,double m_amount,string m_detail);
145 // 结算利息函数
146 void settle(Date m_date);
147 // 打印账户信息
148 void show();
149 //
150 double getCredit();
151 // Current Month Query
152 virtual double getCurMonthBillAmount(Date m_date, string m_bill_kind, string* m_id);
153
154};
155
156
157// 信用卡类
158class CreditAccount:virtual public Account
159{
160 // 累加器
162 // 信用额度
163 double credit;
164 // 利息
165 double rate;
166 // 年费
167 double fee;
169
170
171public:
172 // 信用卡类构造函数
173 CreditAccount(Date m_date, string m_id, double m_credit, double m_rate, double m_fee);
174 // 获取信用额度
175 double getCredit();
176 // 获取利息
177 double getRate();
178 // 获取年费
179 double getFee();
180 // 获取可用额度
181 double getAvailableCredit();
182 // 还款函数
183 void deposit(Date m_date, double m_amount,string m_detail);
184 // 支付函数
185 void withdraw(Date m_date,double m_amount,string m_detail);
186 // 结算利息函数
187 void settle(Date m_date);
188 // 打印账户信息
189 void show();
190 // Current Month Query
191 virtual double getCurMonthBillAmount(Date m_date, string m_bill_kind, string* m_id);
192};
193
194
195#endif /* account_h */
Definition: account.h:73
multimap< Date, AccountRecord > recordMap
Definition: account.h:86
virtual void withdraw(Date m_date, double m_amount, string m_desc)=0
bool has_savings
Definition: account.h:88
static double getTotal()
Definition: account.cpp:181
string getID()
Definition: account.cpp:166
static double total
Definition: account.h:79
virtual ~Account()
Definition: account.cpp:145
double getBalance()
Definition: account.cpp:176
double balance
Definition: account.h:77
void query(Date begin_date, Date end_date)
Definition: account.cpp:186
bool has_credit
Definition: account.h:89
string * getIDPtr()
Definition: account.cpp:171
virtual double getRate()=0
string id
Definition: account.h:75
void record(Date m_date, double m_amount, string m_desc)
Definition: account.cpp:148
virtual void show()=0
virtual void deposit(Date m_date, double m_amount, string m_desc)=0
virtual void settle(Date date)=0
void queryGUI(QDate query_date, multimap< Date, QString > &date_append_temp, multimap< double, QString > &balance_append_temp)
Definition: account.cpp:197
Account(Date m_date, string m_id)
Definition: account.cpp:130
virtual double getCurMonthBillAmount(Date m_date, string m_bill_kind, string *m_id)=0
virtual double getCredit()=0
Definition: account.h:41
void show()
Definition: account.cpp:91
string * id
Definition: account.h:45
string desc
Definition: account.h:51
QString getInfo()
Definition: account.cpp:107
string * getID()
Definition: account.cpp:102
double balance
Definition: account.h:49
AccountRecord()
Definition: account.cpp:86
double amount
Definition: account.h:47
Date date
Definition: account.h:43
double getAmount()
Definition: account.cpp:97
Definition: account.h:15
double sum
Definition: account.h:21
Accumulator()
Definition: account.cpp:44
double value
Definition: account.h:19
void reset(Date m_lastDate, double m_value)
Definition: account.cpp:68
Date lastDate
Definition: account.h:17
double getSum(Date m_date)
Definition: account.cpp:51
void change(Date m_lastDate, double m_value)
Definition: account.cpp:59
Definition: account.h:159
void show()
Definition: account.cpp:467
double credit
Definition: account.h:163
virtual double getCurMonthBillAmount(Date m_date, string m_bill_kind, string *m_id)
Definition: account.cpp:473
void settle(Date m_date)
Definition: account.cpp:436
double getAvailableCredit()
Definition: account.cpp:383
double getRate()
Definition: account.cpp:371
Date a_date
Definition: account.h:168
double rate
Definition: account.h:165
void deposit(Date m_date, double m_amount, string m_detail)
Definition: account.cpp:390
void withdraw(Date m_date, double m_amount, string m_detail)
Definition: account.cpp:404
double getCredit()
Definition: account.cpp:365
Accumulator acc
Definition: account.h:161
CreditAccount(Date m_date, string m_id, double m_credit, double m_rate, double m_fee)
Definition: account.cpp:352
double getFee()
Definition: account.cpp:377
double fee
Definition: account.h:167
Definition: date.h:18
Definition: account.h:130
void withdraw(Date m_date, double m_amount, string m_detail)
Definition: account.cpp:254
Accumulator acc
Definition: account.h:132
double rate
Definition: account.h:134
void deposit(Date m_date, double m_amount, string m_detail)
Definition: account.cpp:239
void show()
Definition: account.cpp:297
double getRate()
Definition: account.cpp:233
double getCredit()
Definition: account.cpp:302
SavingsAccount(Date m_date, string m_id, double m_rate)
Definition: account.cpp:223
void settle(Date m_date)
Definition: account.cpp:273
virtual double getCurMonthBillAmount(Date m_date, string m_bill_kind, string *m_id)
Definition: account.cpp:308
multimap< Date, QString > date_append_temp
Definition: mainwindow.cpp:31
multimap< double, QString > balance_append_temp
Definition: mainwindow.cpp:32
Date date(2008, 11, 1)