c++编写银行管理系统(四)

2014-11-24 10:45:15 · 作者: · 浏览: 2

}
void LinkList::set_head(Node *head)
{
this->head=head;
}
Node *LinkList::get_head()
{
return this->head;
}
int LinkList::get_len()
{
return len;
}
Node *LinkList::make_node(Record *record)
{
Node *node=new Node();
node->set_record(record);
node->set_next(NULL);
return node;
}
void LinkList::insert_node(Node *node)
{
Node *p = this->head;
if (p==NULL)
{
this->head=node;
this->len++;
return ;//必须有return,否则执行while,与p->set_next(node)冲突报告异常

}
while(p->get_next() != NULL)
{
p = p->get_next();
}


p->set_next(node);
this->len++;

return ;
}
Node *LinkList::find_node(int number)
{
Node *p;//要查找的节点
Record *r;//因该是按照账户信息查找(number)
p=this->head;
while(p != NULL)//如果在节点内找到信息,则返回节点,否则,指向下一个节点
{
r=p->get_record();
if (r->get_number()==number)
{
return p;
}
else
{
p=p->get_next();
}
}
return NULL;
}
void LinkList::display_LinkList()
{
Node *p;
p=this->head;
cout<<"Print LinkList.."< if(p == NULL)
{
cout<<"The LinkList is Null"< cout<len< }
else
{
while(p != NULL)
{
p->display_Node();
p=p->get_next();
}
}
cout<<"The len is"<len< cout<<"End of linkList.."<
}

[cpp]
#include "Node.h"
#include
using namespace std;

Node::Node()
{
this->record=NULL;
this->next=NULL;
}
Node::~Node()
{
delete this->record;
this->record=NULL;
this->next=NULL;

}
void Node::set_record(Record *record)
{
this->record=record;

}
void Node::set_next(Node *next)
{
this->next=next;
}
Record *Node::get_record()

{
return this->record;
}
Node *Node::get_next()
{
return this->next;
}
void Node::display_Node()
{
Record *p;
if(this->record != NULL)
{
p=this->record;
p->display();
}
else
{
cout<<"Rcord is null"< }
cout<next< }

[cpp]
#include "Record.h"
#include
#include
using namespace std;
Record::Record()
{
this->flag=0;
this->number=0000;
this->passWord="";
this->salary=0.0;
this->userName="";
}
void Record::set_number(int number)
{
this->number=number;
}
void Record::set_passWord(string passWord)
{
this->passWord=passWord;
}
void Record::set_salary(double salary)
{
this->salary=salary;
}
void Record::set_userName(string userName)
{
this->userName=userName;
}
void Record::set_flag(int flag)
{
this->flag=flag;
}
int Record::get_flag()
{
return flag;
}
int Record::get_number()
{
return number;
}
double Record::get_salary()
{
return salary;
}
string Record::get_userName()
{
return userName;
}
string Record::get_passWord()
{
return passWord;
}
void Record::display()
{

cout<<"**************************************************************************"< cout<<"**用户名:"< cout<<"**************************************************************************"<
}

main
[cpp]
#include "Bank.h"
#include "iostream"
using namespace std;
int flag;
void meanu()
{
cout<<"Welcome to the bank"< cout<<"***********************************************"< cout<<"** 1 开户 ** 2 取款 ** 3 存款 **"< cout<<"***********************************************"< cout<<"** 4 销户 ** 5 账户信息 ** 6 退出 **"< cout<<"***********************************************"< cout<<"请选择:"< } www.2cto.com
int main()
{
Bank *bank = new Bank();
//LinkList *list = bank->get_list();
do
{
meanu();
cin>>flag;
switch(flag)
{
case 1:bank->open_acount();break;
case 2:bank->withdraw();break;
case 3:bank->deposit();break;