课程设计——简单银行储蓄系统(代码)(并不完善版)

问题及代码:main函数/* Copyright (c) 2014,烟台大学计算机学院 *All rights reserved. *文件名称:lily.cpp *作者:李莉 *完成日期:2015年7月17日 *版本号:v1.0 *问题描述:简单的银行储蓄系统, 程序输入:根据业务界面输入程序输出:业务运行结果*/ #include #include
摘要由CSDN通过智能技术生成

问题及代码:

main函数

/*  
Copyright (c) 2014,烟台大学计算机学院  
*All rights reserved.  
*文件名称:lily.cpp  
*作者:李莉  
*完成日期:2015年7月17日  
*版本号:v1.0  
*问题描述:简单的银行储蓄系统, 
程序输入:根据业务界面输入
程序输出:业务运行结果
*/ 

#include <iostream>
#include "bank.h"
#include <ctime>
int main()
{
    cout<<"******************************"<<endl;
    cout<<"** wellcome to Lily's Bank ***"<<endl;
    cout<<"******************************"<<endl;
    if(pass())
    {
        Bank b;
        b.work();
    }
    return 0;
}

Bank的头文件

/*  
Copyright (c) 2014,烟台大学计算机学院  
*All rights reserved.  
*文件名称:lily.cpp  
*作者:李莉  
*完成日期:2015年7月17日  
*版本号:v1.0  
*问题描述:简单的银行储蓄系统, 
程序输入:根据业务界面输入
程序输出:业务运行结果
*/ 
#ifndef BANK_H_INCLUDED
#define BANK_H_INCLUDED
#include <cstring>
using namespace std;
int pass();//银行工作人员登陆,如果登陆成功则执行下面的功能
int chooseInMenue();//选择菜单
int inputPassWord();//输入银行卡的密码
class Bank;//银行业务类
class Work;//主要用于储存业务信息的类
class User
{
public:
    void setUser(int acc,string na,int pa,double bal,int sta,double ti);//录入用户
    void showName();//显示姓名
    void showBalance();//显示余额
    void showprofit();//计算利息
    bool passwordIsRight();//校验密码是否正确
    bool isNormalUser();//检验用户是否状态正常
    friend class Bank;//将bank设置为友元函数,方便bank中的函数访问Uer里面的数据成员
private:
    int account;//银行卡账号
    int password;//设置密码
    string name;//用户姓名
    double balance;//余额
    int status;//0代表正常,1代表挂失,2代表销户
    double time;
};
class Work
{
public:
    friend class Bank;
private:
    int usernum;
    string workinfo;
    string ymd;
    string hms;

};
class Bank
{
public:
    Bank();
    int jishu();//统计文件中有多少用户
    void savework(int usernum,string workinfo);//储存每笔业务
    void readwork();//
    void savefile();//读取文件中保存的每一笔业务
    void work();//业务驱动
    void openAccount();//开户
    void cancelAccount();//销户
    void save();//存款
    void withdrew();//取款
    void showAccount();//显示余额
    void transferAccount();//转账
    void reportLoss();//挂失
    void cancelLoss();//解挂
    void updatePassword();//改密
    void showprofits();//显示利息,
    void searchwork(int a);//查询业务明细
    int getUser();//输入账号查询,并返回用户下标
private:
    int N;
    int n;
    Work yw[2000];
    User *users;
};
#endif // BANK_H_INCLUDED

银行的业务功能函数

/*  
Copyright (c) 2014,烟台大学计算机学院  
*All rights reserved.  
*文件名称:lily.cpp  
*作者:李莉  
*完成日期:2015年7月17日  
*版本号:v1.0  
*问题描述:简单的银行储蓄系统, 
程序输入:根据业务界面输入
程序输出:业务运行结果
*/ 
#include <iostream>
#include <cstring>
#include "bank.h"
#include <fstream>
#include <conio.h>
#include <ctype.h>
#include <cstdlib>
#include <ctime>
using namespace std;
int pass();//银行工作人员登陆,如果登陆成功则执行下面的功能
int chooseInMenue();//选择菜单
int inputPassWord();//输入银行卡的密码
/*******************
*函数功能:构造函数,把文件中已经保存的文件读入数组中
*输入参数:无
*输出参数:无
*其他说明:构造函数中就已经把文件读取了,
*******************/
Bank::Bank()
{
ifstream infile("account.txt",ios::in);
    if(!infile)
    {
        cerr<<"open error!"<<endl;
        exit(1);
    }
    int i=0;
    int acc;
    int pw;
    string nam;
    double bal;
    int sta;
    double ti;
    N=jishu();
    users=new User[N+1];
    while(infile>>acc>>nam>>pw>>bal>>sta>>ti)
    {
        users[i].setUser(acc,nam,pw,bal,sta,ti);
        i++;
    }
    infile.close();
}
/*******************
*功能说明:把后面建立的用户的信息读入到文件中
*输入参数:无
*输出参数:无
*其他说明:无
******************/
void Bank::savefile()
{
    ofstream outfile("account.txt",ios::out);
    if(!outfile)
    {
        cerr<<"open error!"<<endl;
        exit(1);
    }
    for(int i=0; i<N; ++i)
    {
        outfile<<users[i].account<<" "<<users[i].name<<" "<<users[i].password<<" "<<users[i].balance<<" "<<users[i].status<<" "<<users[i].time<<endl;
    }
    outfile.close();

    return;
}
/****************
*函数功能:统计文件中已有的用户数目
*输入参数:无
*输出参数:无
*其他说明:确定动态数组的数组的长度
********************/

int Bank::jishu()
{
    int i=0;
    int account;
    string name;
    int password;
    double balance;
    int status;
    int time;
    ifstream infile("account.txt",ios::in);
    if(!infile)
    {
        cerr<<"open error!"<<endl;
        exit(1);
    }
    while(infile>>account>>name>>password>>balance>>status>>time)
    {
        i++;
    }
    infile.close();
    return i;
}
/********************
*函数功能:读取文件,文件保存的是每个账户的具体操作
*输入参数:无
*输出参数:无
*其他说明:无
********************/
void Bank::readwork()
{
    int i=0;
    ifstream infile("history.txt",ios::in);
    if(!infile)
    {
        cerr<<"open error!"<<endl;
        exit(1);
    }
    while(infile>>yw[i].
  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值