1、C+课程设计 房屋交易系统# define NULL 0# include# include# include# include# include/定义?house类class housepublic: house *next; char *Getadd() return add; char *Getstyle() return style; int Getarea() return area; int Getprice() return price; int Gethouseage() return houseage; char *Getstate() return state; void
2、set_information(char *Nadd,char *Nstyle,int Narea,int Nprice,int Nhouseage,char *Nstate) strcpy(add,Nadd); strcpy(style,Nstyle); area=Narea; price=Nprice; houseage=Nhouseage; strcpy(state,Nstate); private: char add40; char style10; int area; int price; int houseage; char state10;/定义?用?户类class userpu
3、blic: user *next; char *Getname()return name; int GetID()return ID; int Getpassword()return password; void set_information(char *Nname,int id,int passcode) strcpy(name,Nname); ID=id; password=passcode; private: char name20; int ID; int password;/定义?管理员类class managerpublic: manager *next; char *Getna
4、me()return name; int GetID()return ID; int Getpassword()return password; void set_information(char *Nname,int id,int passcode) strcpy(name,Nname); ID=id; password=passcode; private: char name20; int ID; int password;/按地?址查询房?屋Y的?信?息void search_house() char ch40; int sum=0; house *head,*q,*p=new hous
5、e; head=p; char add40; char style10; int area; int price; int houseage; char state10; ifstream file(D:house_information.txt); do coutch; fileaddstyleareapricehouseagestate; p-set_information(add,style,area,price,houseage,state); q=p; while(!file.eof() p=new house; fileaddstyleareapricehouseagestate;
6、 p-set_information(add,style,area,price,houseage,state); q-next=p; q=p; q-next=NULL; file.close(); p=head; while(p!=NULL) if(strcmp(p-Getadd(),ch)=0) sum+; p=p-next; if(sum=0) cout对?不?起e,?信?息库a中D没?有D与?您输?入?的?房?屋Y地?址匹配?的?房?屋Y信?息!?请?重?新?输?入?-Getadd(),ch)=0) coutsetw(40)地?址setw(10)户型setw(10)面?积ysetw(10
7、)价?格?setw(10)房?龄?setw(10)状态?endl; coutsetw(40)Getadd()setw(10)Getstyle()setw(10)Getarea()setw(10)Getprice()setw(10)Gethouseage()setw(10)Getstate()next; while(sum=0);/删?除y房?屋Y信?息void delete_house() char ch40; house *head,*q,*p=new house; head=p; char add40; char style10; int area; int price; int hous
8、eage; char state10; int sum=0; ifstream file1(D:house_information.txt); do coutch; file1addstyleareapricehouseagestate; p-set_information(add,style,area,price,houseage,state); q=p; while(!file1.eof() p=new house; file1addstyleareapricehouseagestate; p-set_information(add,style,area,price,houseage,st
9、ate); q-next=p; q=p; q-next=NULL; file1.close(); p=head; while(p!=NULL) if(strcmp(p-Getadd(),ch)=0) q-next=p-next; delete p; sum+; p=p-next; if(sum=0) cout对?不?起e,?信?息库a中D没?有D与?您输?入?的?房?屋Y地?址匹配?的?房?屋Y信?息!?请?重?新?输?入?-endl; else ofstream file2(D:house_information.txt); p=head; while(p!=NULL) file2Getad
10、d()tGetstyle()tGetarea()tGetprice()tGethouseage()tGetstate()next; q-next=NULL; file2.close(); while(sum=0);/增?加一?条?新?的?房?屋Y信?息void add_house() char add40; char style10; int area; int price; int houseage; char state10; coutaddstyleareapricehouseagestate; ofstream file(D:house_information.txt,ios:app)
11、; filenaddtstyletareatpricethouseagetstate; file.close();/修T改?房?屋Y信?息void modify_house() char ch40; int sum=0; do coutch; house *head,*q,*p=new house; head=p; char add40; char style10; int area; int price; int houseage; char state10; int sum=0; ifstream file1(D:house_information.txt); file1addstylea
12、reapricehouseagestate; p-set_information(add,style,area,price,houseage,state); q=p; while(!file1.eof() p=new house; file1addstyleareapricehouseagestate; p-set_information(add,style,area,price,houseage,state); q-next=p; q=p; q-next=NULL; file1.close(); p=head; while(p!=NULL) if(strcmp(p-Getadd(),ch)=
13、0) strcpy(add,p-Getadd(); strcpy(style,p-Getstyle(); area=p-Getarea(); price=p-Getprice(); houseage=p-Gethouseage(); strcpy(state,p-Getstate(); char choice; do cout请?输?入?您想?要a修T改?的?信?息:on; coutchoice; switch(choice) case a: case A:coutprice;break; case b: case B:couthouseage;break; case c: case C:co
14、utstate;break; default:cout对?不?起e,?您输?入?的?指?令?不?正y确!?请?重?新?输?入?-set_information(add,style,area,price,houseage,state); sum+; p=p-next; if(sum=0) cout对?不?起e,?信?息库a中D没?有D与?您输?入?的?房?屋Y地?址匹配?的?房?屋Y信?息!?请?重?新?输?入?-endl; else ofstream file2(D:house_information.txt); p=head; while(p!=NULL) file2Getadd()tGet
15、style()tGetarea()tGetprice()tGethouseage()tGetstate()next; q-next=NULL; file2.close(); while(sum=0);/按用?户姓?名?查询用?户信?息void search_user() char ch40; int sum=0; user *head,*q,*p=new user; head=p; char name20; int ID; int password; ifstream file(D:user_information.txt); do coutch; filenameIDpassword; p-
16、set_information(name,ID,password); q=p; while(!file.eof() p=new user; filenameID; p-set_information(name,ID,password); q-next=p; q=p; q-next=NULL; file.close(); p=head; while(p!=NULL) if(strcmp(p-Getname(),ch)=0) sum+; p=p-next; if(sum=0) cout对?不?起e,?信?息库a没?有D与?您输?入?的?用?户姓?名?匹配?的?用?户信?息!?请?重?新?输?入?-
17、Getname(),ch)=0) coutsetw(20)姓?名?setw(10)IDendl; coutsetw(20)Getname()setw(10)GetID()next; while(sum=0);/删?除y用?户信?息void delete_user() char ch40; int sum=0; user *head,*q,*p=new user; head=p; char name20; int ID; int password; ifstream file(D:user_information.txt); do coutch; filenameIDpassword; p-se
18、t_information(name,ID,password); q=p; while(!file.eof() p=new user; filenameIDpassword; p-set_information(name,ID,password); q-next=p; q=p; q-next=NULL; file.close(); while(p!=NULL) if(strcmp(p-Getname(),ch)=0) sum+; q-next=p-next; delete p; p=p-next; if(sum=0) cout对?不?起e,?信?息库a中D没?有D与?您输?入?的?用?户姓?名
19、?匹配?的?用?户信?息!?请?重?新?输?入?-endl; else ofstream file2(D:house_information.txt); p=head; while(p!=NULL) file2tGetname()tGetID()tGetpassword()next; q-next=NULL; file2.close(); while(sum=0);/增?加一?条?新?的?用?户信?息void add_user() char name20; int ID; int password; coutnameIDpassword; ofstream file(D:user_inform
20、ation.txt,ios:app); filennametIDtpassword; file.close();/修T改?用?户信?息void modify_user() char ch40; int sum=0; do coutch; user *head,*q,*p=new user; head=p; char name40; int ID; int password; ifstream file1(D:user_information.txt); file1nameIDpassword; p-set_information(name,ID,password); q=p; while(!f
21、ile1.eof() p=new user; file1nameIDpassword; p-set_information(name,ID,password); q-next=p; q=p; q-next=NULL; file1.close(); p=head; while(p!=NULL) if(strcmp(p-Getname(),ch)=0) strcpy(name,p-Getname(); ID=p-GetID(); password=p-Getpassword(); char choice; int passcode; do cout请?输?入?您想?要a修T改?的?信?息:on; coutchoice; switch(choice) case a: case A:coutname;break; case b: case B: do coutpassword; coutpasscode; if(password=passcode) cout密码?设置?成功|!?endl; else cout输?入?的?密码?不?一?致?!?请?重?新?输?入?-endl; while(password!=passcode); break; default:cout对?不?起e,?您输?入?的?指?令?不?正y确
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1