用C++做的房地产管理系统

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include

#include

#include

#include

const int Maxc=100;

const int Maxh=100;

const int Maxbuy=5;

int n;

class Customer{

int payway;

int payout;

int tag;

int no;

char name[10];

int buhouse[Maxbuy];

public:

Customer(){}

char *getname( ) {return name;}

int gettag() {return tag;}

int getno() {return no;}

int getway(int payway){

return payway;

}

int getout(int payout){

return payout;

}

void setname(char na[])

{

strcpy(name,na);

}

void delhouse() {tag=1;}

void addcustomer(int n,char *na)

{

tag=0;

no=n;

strcpy(name,na);

for (int i=0;i

buhouse[i]=0;

}

void buyhouse(int houseid)

{

for (int i=0;i

{

if (buhouse[i]==0)

{

buhouse[i]=houseid;

return;

}

}

}

int checkoffhouse(int houseid)

{

for (int i=0;i

{

if (buhouse[i]==houseid)

{

buhouse[i]=0;

return 1;

}

}

return 0;

}

void disp()

{

cout<

<<"房子编号: [";

for (int i=0;i

if (buhouse[i]!=0)

cout<

cout<<"]"<

}

};

class CDatabase

{

int top;

Customer customer[Maxc];

public:

CDatabase()

{

Customer s;

top=-1;

fstream file("customer.txt",ios::in);

while(1)

{

file.read((char *)&s,sizeof(s));

if (!file) break;

top++;

customer[top]=s;

}

file.close();

}

void clear()

{

top=-1;

}

int addcustomer(int n,char *na)

{

Customer *p=query(n);

if (p==NULL)

{

top++;

customer[top].addcustomer(n,na);

return 1;

}

return 0;

}

Customer *query(int customerid)

{

for (int i=0;i<=top;i++)

if (customer[i].getno()==customerid && customer[i].gettag()==0) return &customer[i];

return NULL;

}

void disp()

{

for(int i=0;i<=top;i++)

customer[i].disp();

}

void customerdata();

~CDatabase()

{

fstream file("customer.txt",ios::out);

for (int i=0;i<=top;i++)

if(customer[i].gettag()==0)

file.write((char *)&customer[i] ,sizeof(customer[i]));

file.close();

}

};

void CDatabase::customerdata()

相关文档
最新文档