用c++编写银行账户管理系统
开发银行账户管理系统,实现增添账户,查询账户记录(余额及历史记录),存取款后修改余额等功能。普通用户可以进行自助查询,管理员可增删账户及存取款、转账及查询等操作。要求将账...
开发银行账户管理系统, 实现增添账户, 查询账户记录(余额及历史记录),存取款后修改余额等功能。
普通用户可以进行自助查询,管理员可增删账户及存取款、转账及查询等操作。
要求将账户信息保存到文件中,从文件中读取数据; 展开
普通用户可以进行自助查询,管理员可增删账户及存取款、转账及查询等操作。
要求将账户信息保存到文件中,从文件中读取数据; 展开
展开全部
4个头文件[cpp] #include "LinkList.h" class Bank { private: LinkList * list; int account_number; public: Bank(); ~Bank(); void set_list(LinkList *list); LinkList *get_list(); LinkList *make_list(); Record *make_record(string userName,string passWord,double balance); int creat_number(); int get_number(); string get_userName(); string get_passWord(); double get_balance(); Record *find_record(int number); void open_acount(); void close_acount();//销户 void find_acount(); void deposit();//存款 void withdraw();//取款 }; [html] #include "Node.h" class LinkList { private: Node *head; int len; public: LinkList(); ~LinkList(); void set_head(Node *head); Node *get_head();//获得头节点 int get_len(); Node *make_node(Record *record);//制作一个节点,目的是插入record void insert_node(Node *node);//插入一个节点 Node *find_node(int number);//找到一个节点,通过账户(number)查找 void display_LinkList(); };
[html] #include "Record.h" class Node { private: Record *record; Node *next; public: Node(); ~Node(); void set_record(Record *record); void set_next(Node *next); Record *get_record(); Node *get_next(); void display_Node(); };
[cpp] #include <iostream> #include <string> using namespace std; class Record { private: int number; double salary; string userName; string passWord; int flag; public: Record(); void set_number(int number); void set_salary(double salary); void set_userName(string userName); void set_passWord(string passWord); void set_flag(int flag); int get_number(); double get_salary(); string get_userName(); string get_passWord(); int get_flag(); void display(); };
4个资源文件文件[cpp] #include "bank.h" #include <iostream> using namespace std; Bank::Bank() { this->list=this->make_list(); this->account_number = 10000; } Bank::~Bank() { delete this->list;//自动调用~LinkList() this->list=NULL; } void Bank::set_list(LinkList *list) { this->list=list; } LinkList *Bank::get_list() { return this->list; } LinkList *Bank::make_list() { return new LinkList(); } Record *Bank::make_record(std::string userName, std::string passWord, double balance) { Record * r = new Record(); int number = this->creat_number(); r->set_number(number); r->set_userName(userName); r->set_passWord(passWord); r->set_salary(balance); r->set_flag(1); return r; } int Bank::creat_number() { return this->account_number = this->account_number+1; } int Bank::get_number() { int number; cout<<"请输入账号....."<<endl; cin>>number; cout<<"账号:"<<number<<endl; return number; } string Bank::get_userName() { string userName; cout<<"请输入用户名....."<<endl; cin>>userName; cout<<"用户名:"<<userName<<endl; return userName; } string Bank::get_passWord() { string paseWord; cout<<"请输入密码....."<<endl; cin>>paseWord; // cout<<"paseWord:"<<paseWord<<endl; return paseWord; } double Bank::get_balance() { double balance; cout<<"请输入金额....."<<endl; cin>>balance; cout<<"金额:"<<balance<<endl; return balance; } Record *Bank::find_record(int number) { Node *n=this->list->find_node(number); if(n != NULL) { return n->get_record(); } return NULL; } void Bank::open_acount() { //1获取账户输入的信息 string userName=this->get_userName(); string passWord=this->get_passWord(); double balance = this->get_balance(); //2 使用输入数据创建record 记录 Record *r = this->make_record(userName,passWord,balance); //3 创建node节点,封装record记录 Node *n=this->list->make_node(r); //4将node节点插入到linkliast this->list->insert_node(n); cout<<"您的账号是"<<this->account_number<<endl; } void Bank::close_acount() { int i=3; int flag; // 1 获取账户信息 int number = this->get_number(); string passWord = this->get_passWord(); // 2 在链表中找到账节点,找到账户信息 Node *node=this->list->find_node(number); if(node == NULL) { cout<<"账户不存在"<<endl; return ; } Record *record =node ->get_record(); // 3 密码验证 for(i=3;i>=1;i--) { if(record->get_passWord() == passWord) // 4 用户状态改变 { do { cout<<"确定要销户?(0 销户,1 不销户)"<<endl; cin>>flag; if(flag == 1) { record->set_flag(flag); return ; } else if(flag == 0) { record->set_flag(flag); record->set_salary(0); return ; } else { cout<<"输入错误,请重新输入"<<endl; } } while(1); cout<<"还有"<<i<<"次机会"<<endl; } } } void Bank::deposit() { int balance=0; //1 获取账户账号以及密码 int number = this->get_number(); string passWord = this->get_passWord(); //2 从链表中找到账户信息 Node *node=this->list->find_node(number); if(node == NULL) { cout<<"账户不存在"<<endl; return ; } Record *record =node ->get_record(); //3 密码验证,存款 if(record->get_passWord() == passWord) { double balance=this->get_balance()+record->get_salary(); record->set_salary(balance); cout<<"存款成功"<<endl; return ; } } void Bank::withdraw() { int balance=0; //1 获取账户账号以及密码 int number = this->get_number(); string passWord = this->get_passWord(); //2 从链表中找到账户信息 Node *node=this->list->find_node(number); if(node == NULL) { cout<<"账户不存在"<<endl; return ; } Record *record =node ->get_record(); //3 密码验证,取款 if(record->get_passWord() == passWord) { double balance=record->get_salary()-this->get_balance(); if(balance>=0) { record->set_salary(balance); cout<<"取款成功"<<endl; return ; } else { cout<<"您的余额不足"<<endl; return ; } } } void Bank::find_acount() { int number = this->get_number(); string passWord = this->get_passWord();
return 0; }
[html] #include "Record.h" class Node { private: Record *record; Node *next; public: Node(); ~Node(); void set_record(Record *record); void set_next(Node *next); Record *get_record(); Node *get_next(); void display_Node(); };
[cpp] #include <iostream> #include <string> using namespace std; class Record { private: int number; double salary; string userName; string passWord; int flag; public: Record(); void set_number(int number); void set_salary(double salary); void set_userName(string userName); void set_passWord(string passWord); void set_flag(int flag); int get_number(); double get_salary(); string get_userName(); string get_passWord(); int get_flag(); void display(); };
4个资源文件文件[cpp] #include "bank.h" #include <iostream> using namespace std; Bank::Bank() { this->list=this->make_list(); this->account_number = 10000; } Bank::~Bank() { delete this->list;//自动调用~LinkList() this->list=NULL; } void Bank::set_list(LinkList *list) { this->list=list; } LinkList *Bank::get_list() { return this->list; } LinkList *Bank::make_list() { return new LinkList(); } Record *Bank::make_record(std::string userName, std::string passWord, double balance) { Record * r = new Record(); int number = this->creat_number(); r->set_number(number); r->set_userName(userName); r->set_passWord(passWord); r->set_salary(balance); r->set_flag(1); return r; } int Bank::creat_number() { return this->account_number = this->account_number+1; } int Bank::get_number() { int number; cout<<"请输入账号....."<<endl; cin>>number; cout<<"账号:"<<number<<endl; return number; } string Bank::get_userName() { string userName; cout<<"请输入用户名....."<<endl; cin>>userName; cout<<"用户名:"<<userName<<endl; return userName; } string Bank::get_passWord() { string paseWord; cout<<"请输入密码....."<<endl; cin>>paseWord; // cout<<"paseWord:"<<paseWord<<endl; return paseWord; } double Bank::get_balance() { double balance; cout<<"请输入金额....."<<endl; cin>>balance; cout<<"金额:"<<balance<<endl; return balance; } Record *Bank::find_record(int number) { Node *n=this->list->find_node(number); if(n != NULL) { return n->get_record(); } return NULL; } void Bank::open_acount() { //1获取账户输入的信息 string userName=this->get_userName(); string passWord=this->get_passWord(); double balance = this->get_balance(); //2 使用输入数据创建record 记录 Record *r = this->make_record(userName,passWord,balance); //3 创建node节点,封装record记录 Node *n=this->list->make_node(r); //4将node节点插入到linkliast this->list->insert_node(n); cout<<"您的账号是"<<this->account_number<<endl; } void Bank::close_acount() { int i=3; int flag; // 1 获取账户信息 int number = this->get_number(); string passWord = this->get_passWord(); // 2 在链表中找到账节点,找到账户信息 Node *node=this->list->find_node(number); if(node == NULL) { cout<<"账户不存在"<<endl; return ; } Record *record =node ->get_record(); // 3 密码验证 for(i=3;i>=1;i--) { if(record->get_passWord() == passWord) // 4 用户状态改变 { do { cout<<"确定要销户?(0 销户,1 不销户)"<<endl; cin>>flag; if(flag == 1) { record->set_flag(flag); return ; } else if(flag == 0) { record->set_flag(flag); record->set_salary(0); return ; } else { cout<<"输入错误,请重新输入"<<endl; } } while(1); cout<<"还有"<<i<<"次机会"<<endl; } } } void Bank::deposit() { int balance=0; //1 获取账户账号以及密码 int number = this->get_number(); string passWord = this->get_passWord(); //2 从链表中找到账户信息 Node *node=this->list->find_node(number); if(node == NULL) { cout<<"账户不存在"<<endl; return ; } Record *record =node ->get_record(); //3 密码验证,存款 if(record->get_passWord() == passWord) { double balance=this->get_balance()+record->get_salary(); record->set_salary(balance); cout<<"存款成功"<<endl; return ; } } void Bank::withdraw() { int balance=0; //1 获取账户账号以及密码 int number = this->get_number(); string passWord = this->get_passWord(); //2 从链表中找到账户信息 Node *node=this->list->find_node(number); if(node == NULL) { cout<<"账户不存在"<<endl; return ; } Record *record =node ->get_record(); //3 密码验证,取款 if(record->get_passWord() == passWord) { double balance=record->get_salary()-this->get_balance(); if(balance>=0) { record->set_salary(balance); cout<<"取款成功"<<endl; return ; } else { cout<<"您的余额不足"<<endl; return ; } } } void Bank::find_acount() { int number = this->get_number(); string passWord = this->get_passWord();
return 0; }
追问
谢谢啦哈,好心人!!!
对了,问一下哈,您能不能给用Word文档给整理一下,看起来有点乱诶....
好心人,帮帮忙,整理好给发有邮箱里呗...邮箱jiangbaoliang123@163.com,
在此,发自内心的感谢!!!
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询