没有合适的资源?快使用搜索试试~ 我知道了~
57119101_王晨阳_实验报告1
需积分: 0 0 下载量 61 浏览量
2022-08-03
18:45:01
上传
评论
收藏 599KB PDF 举报
温馨提示
试读
34页
3. 基本查询功能 6. 可选功能提升:统计今后 3 天每天到期的储金数,以便备款 1. 用户列表、流水列表导出到 html 表格 1. 软件结构 2. 数据库
资源推荐
资源详情
资源评论
语言课程设计实验报告
姓 名
王晨阳
学 号
57119101
专 业
网络空间安全
起始日期
2021 年 7 月
结束日期
2021 年 7 月
总评
(教师填
写)
设 计 文 档
设
计
任
务
银行储蓄管理系统
[要求] 该系统需创建和管理以下信息:1、储户信息:帐号、姓名、密码、地址、储种(定期1年、3
年、5年)、利息(1年到期利率1.98%;3年到期利率2.25%:5年到期利率3.5%)、是否已挂失、挂
失日期、营业员工号、存取款数据集;2、存取款信息:日期、金额、业务类型(存或取)、营业员工号。
系统功能要求如下:
1.创建和管理储户:创建储户对象(开户);
2.登陆账户:根据储户的帐号、密码登陆账户,有则登录。1)在里面可修改储户信息、账户挂失等;
2)办理存取款业务,将存取款对象数据加入到储户对象的数据成员中;
3. 基本查询功能;
4.数据文件读写:文件中包含所有储户信息、每个储户的存取款业务等数据;
5.基本信息显示:1)显示所有储户信息;2)显示特定储户的存取款业务;
6. 可选功能提升:统计今后 3 天每天到期的储金数,以便备款;2)本金和利息计算等。
扩展功能
1. 用户列表、流水列表导出到 html 表格
设
计
实
现
的
方
法
1. 软件结构
目前的软件结构模型如下:
最下层 database 实现数据存取、密码验证;中间层 server 实现合法性验证、用户登录等,沟通数
据库与用户界面; 最上层为用户界面,所有用户界面等级相同,互相切换; calculator 为辅助函数库,同
时与数据库及服务层交互。
对于上面的模型,中间层 server 看起来可以和最底层合并,但这样的设计是为了更方便扩展为最
终版本:
这是一个多用户、易扩展、层次化的模型。
2. 数据库实现
数据库采用 4 层嵌套结构,存储结构如下:
我们使用 vector 实现可变容、可按索引查找的数据存储。
为了实现更加高效的账号查找,我们使用 map 进行了映射,如下图所示
这将账号搜索的时间复杂度从 O(n) 降低到了 O(1)。
为了确保数据安全,防止软件运行中因不可抗拒因素强制关闭,我们规定数据库在内存中进行任
何读写后都立即将数据写入磁盘文件。这是以效率换稳定,增强软件鲁棒性。
3. 利息计算
由于存在非同时存储、不确定取款金额、滚利计算等几大难点,我们创造性地使用了链表式流水
表单,如下图所示
每当有存款时,链表向后增加一条记录;
每当有取款时,链表检查最后一项,如果小于要取的金额,则扣除取款金额;否则删除最后一项,
继续比较前面的项;
每当要查询时,只需从表头扫描到表尾,计算出每一个存款记录的利息。
这样的结构使得分开计算每一笔存款成为可能。
4. 其余功能实现
由于需求较为简单,其余功能全部简单模拟即可。
5. 功能特色
- 创建账户时,账号自动生成,作为账户唯一标识符
- 密码存取实现严格管理,仅数据库有读取密码的权限,同时隔离数据库与用户操作界面
- 一键以标准格式导出数据,方便数据查看、携带及二次处理
- 性能优化,账户数目较多时,各项操作效率优于平凡算法
- 数据保护,始终同步内存与外存,软件鲁棒性大大提高
关
键
代
码
软件所有代码均使用 git 进行管理,并同步至
我的
GitHub
仓库(点击查看)
以下为数据库模块、计算模块的关键代码以及详细注释:
说
明
bankdb.h
/************************************************************************
* Copyright (C) 2021 Chenyang https://wcy-dt.github.io *
* *
* @file bankdb.h *
* @brief Bankdb simulates a database for the project. The speed of *
* this database is slow for that we must ensure the safety *
* of every deal. *
* @author Chenyang *
* @date 2021 - 07 *
************************************************************************/
#ifndef BANKDB_H
#define BANKDB_H
#include <map>
#include <string>
#include <vector>
using namespace std;
class bankdb
{
public:
bankdb();
/**
* @defgroup file operations
*/
void GetFile();
void WriteFile();
/**
* @defgroup account operations
*/
void AddAccount(string, string, string, string, int, double, string);
void EditAccount(string, string, string, int, double);
void EditPasswd(string, string);
void SetLost(string, time_t);
bool ExistAccount(string);
bool CheckAccount(string, string);
/**
* @defgroup get information by account number
*/
string GetName(string);
/**
* @defgroup get information by the index in vAccount
*/
string GetName(int);
/**
* @defgroup get number
*/
int GetNumberOfAccounts();
int GetNumberOfFlows(string);
/**
* @defgroup get information of the flow by account number
* and index of the flow
*/
time_t GetTime(string, int);
double GetMoney(string, int);
int GetOperationType(string, int);
string GetOperator(string, int);
/**
* @defgroup deposit and withdraw money
*/
void DepositMoney(string, time_t, double, string);
bool WithdrawMoney(string, time_t, double, string);
private:
/**
* @brief This structure records the flow for every account.
*/
struct flowInfo
{
time_t tTime; /// when the deal happens
double dMoney; /// how much money
int iOperationType; /// the type of the operation,
/// -# 0:deposit
/// -# 1:withdraw
string strOperator; /// the operator of the deal
};
/**
* @brief This structure records the information of every accounts.
*/
struct accountInfo
{
剩余33页未读,继续阅读
资源评论
BJWcn
- 粉丝: 28
- 资源: 294
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功