訂餐系統c代碼_第1頁
訂餐系統c代碼_第2頁
訂餐系統c代碼_第3頁
訂餐系統c代碼_第4頁
訂餐系統c代碼_第5頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、訂餐系統代碼#include<iostream>#include<fstream>#include<iomanip>#include<cstring>using namespace std; /菜單種類最大值#define MAX 20int static m=0;int static i=0;int static pass=0;int compare(char *a,char *b)/比對用戶名和密碼for(int i=0;i<20;i+)if(*a+!=*b+)return 0; return 1;/完全匹配 /客戶信息 struct

2、Client char name20;char password20;/注冊會員(存儲客戶信息)&&用戶登入void Register( ) Client user; int n;cout<<"您是否為會員?(0否 or 1是)"<<endl; cin>>n; if(n=0) cout<<"*用戶注冊模塊*"<<endl<<"請輸入."<<endl<<"注冊用戶名:" ofstream client(&q

3、uot;用戶信息.txt");if(!client)cout<<"用戶信息打開失?。?quot;<<endl;return; cin>>; cout<<"注冊密碼:" cin>>user.password; /保存用戶信息 client<<'_'<<<<','<<user.password<<endl; cout<<"注冊成功!"<

4、<endl; pass=1; else cout<<"請輸入."<<endl; cout<<"用戶名:" cin>>; cout<<endl<<"密碼:"cin>>user.password;ifstream guest("用戶信息.txt");if(!guest)cout<<"用戶信息.txt打開失敗!"<<endl;return; /比對輸入的用戶信息和已存儲的

5、用戶信息char name20,password20,ch;int i=0,j=0; while(guest>>ch&&j<20) for( i=0;i<20;i+)if(ch=',')break; if(ch='_')guest>>ch;namei=ch; for(i=0;i<20;i+) if(ch='_')break; if(ch=',')guest>>ch;passwordi=ch; if(compare(,name)=1)&&

6、amp;(compare(user.password,password)=1)cout<<"用戶登入成功!"<<endl;pass=1;break; j+; if(pass=0)cout<<"登錄失敗!請檢查用戶名和密碼輸入是否正確!"<<endl; void Convert( )/購物車,今日菜單 char cf,s20; int j=0,k=0; int n; ofstream out("購物車.txt"); if(!out)cout<<"購物車.txt打開失敗

7、!"<<endl;return ;ofstream Menu("今日菜單.txt"); if(!Menu)cout<<"今日菜單.txt打開失敗!"<<endl;return ; cout<<"*"<<"購物車模塊"<<"*"<<endl; cout<<1<<' '<<"添加菜單名"<<endl<<2<

8、<' '<<"購物車內容"<<endl<<3<<' '<<"刪除菜單名"<<endl<<4<<' '<<"生成今日菜單"<<endl<<5<<' '<<"退出購物車"<<endl; for(cout<<".",cin>>n;n!=5;co

9、ut<<".",cin>>n) if(n=1) cout<<"-添加菜單名(!結束輸入):"<<endl;/添加菜單名 cin>>cf; while(cf!='!') out<<cf; si=cf; /寫購物車 out<<' ' i+;/全局變量i /i個菜名 cin>>cf; cout<<endl; out.close();if(n=2)cout<<"-購物車內容:"<<

10、endl; for(j=0;j<i;j+) cout<<sj<<"," cout<<endl; if(n=3)cout<<"-刪除菜單名(!結束輸入):"<<endl;/刪除菜單名 for(cin>>cf;cf!='!'cin>>cf)/對比輸入單號for(j=0;j<i;j+)if(sj=cf)sj=' 'k=1; if(k=1)cout<<"您的操作成功!"<<endl; if(n

11、=4) /提交訂單 j=0; while(j<i)/選擇寫入今日菜單.txt Menu<<sj<<' 'k=3;j+; Menu.close();if(k=3)cout<<"今日菜單生成!"<<endl; out.close();Menu.close(); /今日菜單模塊,留言板模塊,購物車模塊,注冊登錄模塊,用戶中心模塊void Show(ifstream &y)/顯示函數 char ch; while(y>>ch)if(ch>='1'&&ch&

12、lt;='MAX')cout<<" " cout<<ch; cout<<endl;void message(ofstream &c)/留言模塊char ch; cin>>ch; while(ch!='!') c<<ch;cin>>ch; cout<<endl<<"-謝謝您的留言,我們會努力做得更好!"<<endl;int main()char n,ch; int i=0,k=0,option; ofstrea

13、m Message("留言.txt"); if(!Message)cout<<"留言.txt打開失??!"<<endl;return 1; ofstream Menu("今日菜單.txt"); if(!Menu)cout<<"今日菜單.txt打開失?。?quot;<<endl;return 1; ifstream y1("新菜推薦.txt"); if(!y1)cout<<"新菜推薦.txt打開失敗!"<<endl;r

14、eturn 1; ifstream y2("熱菜推薦.txt"); if(!y2)cout<<"熱菜推薦.txt打開失敗!"<<endl;return 1; ifstream y3("食堂動態.txt"); if(!y3)cout<<"食堂動態.txt打開失?。?quot;<<endl;return 1; ifstream menu("今日菜單.txt"); if(!menu)cout<<"今日菜單.txt打開失敗!"<

15、<endl;return 1; Register(); if(pass=0)return 1;cout<<"*"<<"歡迎進入訂餐系統"<<"*"<<endl;cout<<endl<<1<<' '<<"熱菜推薦"<<endl<<2<<' '<<"新菜推薦"<<endl <<3<<&

16、#39; '<<"購物車" <<endl<<4<<' '<<"食堂動態"<<endl <<5<<' '<<"今日菜單"<<endl<<6<<' '<<"留言" <<endl <<7<<' '<<"退出系統!"<<

17、endl;cout<<"*"<<endl;cout<<"。"for(cin>>option;option!=7;cout<<"。",cin>>option)switch(option) case 1:Show(y1);cout<<"-"<<endl;break;/顯示熱菜推薦 case 2:Show(y2);cout<<"-"<<endl;break;/顯示新菜推薦 case

18、3:Convert( );break; /錄入您選擇的菜號,輸入完畢可以查看購物車 case 4:/顯示食堂動態 cout<<"-"<<"今日食堂動態:"<<"-"<<endl; while(y3>>ch) if(ch=',')cout<<endl;continue; cout<<ch; cout<<endl<<"-"<<endl; break; case 5: /顯示今日菜單內容菜單cout<<"您今日菜單如下:"<<endl;Show(menu);

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論