⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ustomer.cpp

📁 看看
💻 CPP
字号:
// USTOMER.cpp: implementation of the CUSTOMER class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "银行系统.h"
#include "USTOMER.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////


int CUSTOMER::count = 1000;
int CUSTOMER::numofclass = 0;

//////////////////////////////////////////////////////////////////////
//构造函数,析构函数
//////////////////////////////////////////////////////////////////////
//——————————————————————————————————
CUSTOMER::CUSTOMER(CString nname,long npassword,CString naddress,
				   int ntype,double nbase,time_t nindate):
                   indate(nindate),missdate(0)
{
	account = ++count;
	name = nname;
	password = npassword;
	address = naddress;
    atype = ntype;
	base = nbase;
    ismiss = FALSE;
	CTimeSpan span(365*ntype,0,0,0);
	outdate = indate + span;

	numofclass++;
}

//——————————————————————————————————
CUSTOMER::CUSTOMER(CUSTOMER &a)
{
	account = a.account;
	name = a.name;
	password = a.password;
    address = a.address;
	atype = a.atype;
	base = a.base;
	indate = a.indate;
	ismiss = a.ismiss;
	missdate = a.missdate;
	outdate = a.outdate;
	numofclass++;
}

//——————————————————————————————————
CUSTOMER::CUSTOMER(long naccount)
{
	account = naccount;
}

//——————————————————————————————————
CUSTOMER::~CUSTOMER()
{
	numofclass--;
}

//////////////////////////////////////////////////////////////////////
//链表函数
//////////////////////////////////////////////////////////////////////

//——————————————————————————————————
CUSTOMER *CUSTOMER::Gethead()
{
	return &MyDoc->customerlist.GetHead();
}

//——————————————————————————————————
int CUSTOMER::DelP(CUSTOMER *desti)
{
	if(MyDoc->customerlist.IsEmpty()) return 0;
	MyDoc->customerlist.RemoveAt(MyDoc->customerlist.Find(*desti));
	if(MyDoc->customerlist.IsEmpty()) return 0;
	return 1;
}//返回0表示链表已空,返回1表示链表未空。

//——————————————————————————————————
void CUSTOMER::DelAll()
{
	MyDoc->customerlist.RemoveAll();
}

//——————————————————————————————————
CUSTOMER *CUSTOMER::Find(long naccount)
{
	POSITION position;
	if(!(position = MyDoc->customerlist.Find(CUSTOMER(naccount)))) return NULL;
	return &MyDoc->customerlist.GetAt(position);
}//若返回NULL表示未找到。

//——————————————————————————————————
//如果不写着两个函数就会有连接错误。
int CUSTOMER::DelP(CUSTOMER *desti,CUSTOMER *pre)
{
	return 0;
}

CUSTOMER *CUSTOMER::FindPre(CUSTOMER now)
{
	return NULL;
}//返回NULL表示无前指针

//////////////////////////////////////////////////////////////////////
//重载操作符。
//////////////////////////////////////////////////////////////////////
//——————————————————————————————————
CUSTOMER &CUSTOMER::operator =(CUSTOMER &a)
{
	account = a.account;
	name = a.name;
	password = a.password;
    address = a.address;
	atype = a.atype;
	base = a.base;
	indate = a.indate;
	ismiss = a.ismiss;
	missdate = a.missdate;
	outdate = a.outdate;
	return *this;
}

//——————————————————————————————————
bool CUSTOMER::operator ==(const CUSTOMER &a)
{
	if(account == a.account)return true;
	return false;
}

//——————————————————————————————————
bool operator ==(const CUSTOMER &a,const CUSTOMER &b)
{
	if(a.account == b.account) return true;
	return false;
}

//////////////////////////////////////////////////////////////////////
//序列化
//////////////////////////////////////////////////////////////////////
//——————————————————————————————————
void CUSTOMER::Serialize(CArchive &ar)
{
    if(ar.IsStoring())
	{	
		ar <<account <<address <<atype <<base 
		   <<indate <<ismiss <<missdate <<name <<outdate
	       <<password;
	}   
	else
	{
		ar >>account >>address >>atype >>base
		   >>indate >>ismiss >>missdate >>name >>outdate
	       >>password;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -