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);
&nb
补充:软件开发 , C++ ,