




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、C+電商交易平臺設(shè)計(jì)班級:2013211306 姓名:嚴(yán)浩 學(xué) 號:2013211321實(shí)驗(yàn)?zāi)康腻憻捨覀冇胏+編程的能能力培養(yǎng)我們考慮問問題是否全面面的能力訓(xùn)練我們的代碼碼優(yōu)化能力基本內(nèi)容題目一:銀行門門戶的設(shè)計(jì)該門戶是一個個單獨(dú)的程序序,程序要求求至少支持以以下功能:注冊銀行卡,銀銀行可選;修改銀行卡密碼碼;存款取款;銀行卡至少需要要有卡號,密密碼,所屬銀銀行名稱,持持卡人身份證證號,卡內(nèi)金金額等內(nèi)容。要求1:請把所所有的銀行名名寫入文件(或或數(shù)據(jù)庫),注注冊銀行卡的的時候,要求求只能選擇已已經(jīng)存在的銀銀行進(jìn)行注冊冊。要求2:請做好好錯誤場景的的處理,例如如讀銀行文件錯錯誤,輸入數(shù)數(shù)據(jù)不合法
2、等等等。題目二:電商平平臺的設(shè)計(jì)該平臺是銀行行門戶之外的的一個單獨(dú)的的程序,程序序要求至少支支持以下功能能:注冊&登錄:支支持新用戶注注冊平臺賬號號,已注冊用用戶用平臺賬賬號登錄平臺臺。(要求已已注冊用戶的的信息長久保保留。)瀏覽平臺產(chǎn)品信信息。優(yōu)惠活動:支持持對同一品類類下所有產(chǎn)品品打折的活動動,支持單筆筆訂單滿X減減Y的活動。購買產(chǎn)品:支持持用戶添加產(chǎn)產(chǎn)品到購物車車,查看實(shí)際際應(yīng)付的產(chǎn)品品價格,提交交訂單。在題目二我們暫暫時不考慮提提交訂單后支支付等后續(xù)需需求。要求1:電商平平臺上至少有有三類產(chǎn)品:如食物、服服裝、圖書等等,每類產(chǎn)品品中至少有三三個具體的產(chǎn)產(chǎn)品(如圖書書中可以有CC+ Pr
3、rimer、EEfferttive CC+等),每每個具體的產(chǎn)產(chǎn)品請至少包包含產(chǎn)品描述述,產(chǎn)品原價價,產(chǎn)品剩余余量等數(shù)據(jù)。所所有的產(chǎn)品信信息需要存儲儲在數(shù)據(jù)庫或或文件中,不不能寫在代碼碼中,平臺管管理員通過直直接修改數(shù)據(jù)據(jù)庫或文件,管管理本平臺上上的產(chǎn)品,包包括產(chǎn)品的增增加和刪除,修修改數(shù)量以及及具體產(chǎn)品的的屬性信息等等。要求2:請至少少設(shè)計(jì)一層繼繼承體系(產(chǎn)產(chǎn)品基類-產(chǎn)產(chǎn)品子類),設(shè)設(shè)計(jì)一個產(chǎn)品品基類,然后后讓圖書類、電電子產(chǎn)品類和和服裝類等產(chǎn)產(chǎn)品子類類繼繼承它,具體體的產(chǎn)品是產(chǎn)產(chǎn)品子類的實(shí)實(shí)例對象( 是圖書類類的實(shí)例對象象) 。產(chǎn)品品基類請至少具具有一個虛函函數(shù)getPPrice()用于計(jì)
4、算算具體產(chǎn)品的的價格。要求3:請通過過為每個產(chǎn)品品子類定義“品品類折扣系數(shù)數(shù)”來支持對對同產(chǎn)品子類類下所有產(chǎn)品品打折扣的活活動(如圖書書全場5折,則則圖書類這一一產(chǎn)品子類的的折扣系數(shù)為為0.5)。要求4:請做好好錯誤場景的的處理。題目三:網(wǎng)上支支付的設(shè)計(jì)實(shí)現(xiàn)題目三會讓讓你設(shè)計(jì)的平平臺像個真正正的運(yùn)行在網(wǎng)網(wǎng)絡(luò)上的平臺臺。題目三要要求在題目一一、二的基礎(chǔ)礎(chǔ)上支持通過過網(wǎng)上支付在在電商平臺上上購物,請至至少實(shí)現(xiàn)以下下功能:綁定銀行卡:支支持電商平臺臺賬號綁定銀銀行卡。同一一賬號可以綁綁定多張銀行行卡,而且銀銀行卡可以屬屬于不同銀行行。網(wǎng)上支付:選擇擇綁定的任一一銀行卡支付付電商平臺上上的訂單。要求1
5、:綁定銀銀行卡和選擇擇銀行卡進(jìn)行行支付時都要要求提供對應(yīng)應(yīng)的銀行卡密密碼。要求2:當(dāng)在電電商平臺上綁綁定銀行卡或或者進(jìn)行網(wǎng)上上支付的時候候,請不要直直接打開某個個文件查找銀銀行卡的信息息,因?yàn)殂y行行卡信息文件件是銀行門戶戶系統(tǒng)私有的的,電商平臺臺系統(tǒng)無法直直接訪問,而而應(yīng)該由電商商平臺系統(tǒng)去去向銀行門戶戶系統(tǒng)對接數(shù)數(shù)據(jù)。請用ssockett通信來傳送送數(shù)據(jù)。要求3:請做好好錯誤場景的的處理,如綁綁定銀行卡失失敗,支付失失敗等。實(shí)驗(yàn)方法題目一:創(chuàng)建了銀行卡類類、銀行門戶類類,銀行卡里里包含了卡號號、姓名、密密碼、身份證證號、銀行名名稱、余額幾幾個屬性。銀行門戶有操作作銀行卡,注注冊銀行卡兩兩個功
6、能,操操作銀行卡又又包括存取款款,修改密碼碼等功能,賬賬戶信息和銀銀行名稱保存存在文件里,銀銀行卡用veector類類型保存。題目二:創(chuàng)建了電商平臺臺類、賬戶類類、商品類(商商品類有3個派生類)、綁定銀行卡類、購物車項(xiàng)目類。其中賬戶類中包含了用戶名、密碼、手機(jī)號、購物車、應(yīng)付款、綁定銀行卡、綁定銀行卡數(shù)量這幾個屬性,其中購物車?yán)锏捻?xiàng)目用vector類型保存。電商平臺中的賬賬戶也用veector類類型保存,平平臺的功能有有:登錄、注注冊,登錄后后可以綁定銀銀行卡、查看看商品并添加加購物車、查查看購物車和和應(yīng)付金額、結(jié)結(jié)算購物車、退退出登錄等功功能。題目三:在綁定銀行卡和和付款時用ssockett
7、通信來傳送送數(shù)據(jù)。綁定銀行卡時,先先向銀行門戶戶發(fā)送綁定銀銀行卡標(biāo)志位位表示綁定功功能,然后發(fā)發(fā)送卡號密碼碼,驗(yàn)證通過過后返回成功功標(biāo)志位,電電商平臺收到到后綁定成功功。付款時,先向銀銀行門戶發(fā)送送付款標(biāo)志位位表示付款功功能,然后后發(fā)送卡號密密碼,驗(yàn)證通通過后返回成成功標(biāo)志位,電電商平臺收到到后發(fā)送應(yīng)付付金額,銀行行門戶收到后后調(diào)用付款函函數(shù),余額不不足返回余額額不足標(biāo)志位位,余額夠則則返回付款成成功標(biāo)志位。源代碼 銀行門戶代代碼: #ifnddef _BBANKCAARD_H_#definee _BANKKCARD_H_#includde#includdeusing nnamesppace
8、sstd;class bbankcaardprivatte: striing caardnumm; striing paassworrd; striing baanknamme; striing naame; striing IDD; doubble reemaindder; publicc: bankkcard() bankkcard(strinng numm,striing paassworrd,strring bbanknaame,sttring name,strinng ID,doublle remmaindeer); voidd setPPasswoord(sttring passw
9、word); voidd addRRemainnder(ddoublee moneey); voidd subRRemainnder(ddoublee moneey); striing geetCarddnum(); striing geetPasssword(); striing geetBankkname(); striing geetNamee(); striing geetID(); doubble geetRemaainderr(); booll matcchPasssport(strinng passswordd); ofsttream& operrator cardnnum=ca
10、ardnumm;this-passwword=ppasspoort;this-banknname=bbanknaame;this-name=name;this-ID=IDD;this-remaiinder=remaiinder;void baankcarrd:seetPasssword(strinng newpaassporrt)this-passwword=nnewpasssportt;void baankcarrd:adddRemaainderr(doubble moneyy)this-remaiinder+=moneey;void baankcarrd:suubRemaainderr(d
11、oubble moneyy)this-remaiinder=this-remaiinder-moneyy;string bankccard:getCaardnumm()returnn carddnum;string bankccard:getPaassworrd()returnn passsword;string bankccard:getBaanknamme()returnn bankkname;string bankccard:getNaame()returnn namee;string bankccard:getIDD() retturn IID; double bankccard:ge
12、tReemaindder()returnn remaainderr;bool baankcarrd:maatchPaassporrt(strring passwword)if(thiis-paassworrd=paassworrd) retuurn true; elsse returrn falsee;ofstreaam& bankkcard:operrator (offstreaam& ofs)ofs 卡號:carrdnum;ofs 密碼:passswordd;ofs 銀行:bannknamee;ofs 姓名:namme;ofs 身份證號號:ID;ofs 余額:deccremmaindeer
13、enndl; retturn ofs;#ifndeff BANKKPORTAAL_H#definee BANKPPORTALL_H#includde #includde #pragmaa commeent(lib,ws2_32.liib)#includde #includde #includde bankkcard.husing sstd:vvectorr;class BBankPoortalprivatte:vectoor vBBankN;vectoor vBankkC;void init();void regissterBaankC();void loginnBankCC();void c
14、hanggePasssword(int inndex);void depossit(innt inddex);void withddraw(iint inndex);int mmatch(strinng carrdnum);bool checkk(striing caardnumm);void outpuut();void bankNNamingg();doublle StrrToDouuble(sstringg str, int sttart, int ennd);void Bind();bool pay(sstringg num,doublle monney);int MMatch(str
15、inng useernamee,striing paassworrd);publicc:BankPPortall(); #endif#includde #includde #includde #includde #includde #includde #includde bankkportaal.hconst sstringg bankkname_file = baanknamme.txtt;const sstringg outpput_fiile = outpput.txxt;BankPorrtal:BankPPortall()init();cout SSelectt) | (Seleect
16、0 != 1 & Seleect0 != 2)coutt 輸入錯誤,請請重新輸入: enndl;cout enndl; Choicce=stdd:atooi(Sellect.cc_str();if(Chooice=2) Binnd();while(true)cout enndl;cout =歡迎來到到銀行門戶= enddl;cout = endl;cout =您想進(jìn)行行什么操作?= endll;cout =1:操作作賬戶 = endll;cout =2:注冊冊銀行卡 = endl;cout =3:退出出 = enndl;cout = endl enddl;cout SSelectt) | Se
17、lecct0 3)coutt 輸入錯誤,請請重新輸入: enndl;cout enndl; selecct=stdd:atooi(Sellect.cc_str();switcch(selecct)casee 1:logginBannkC();breeak;casee 2:reggisterrBankCC();breeak;casee 3:outtput();retturn;defaault:breeak;void BaankPorrtal:regissterBaankC()cout 請選擇你要要注冊的銀行行: enndl;for(unnsigneed int i=0;ivvBankNN.siz
18、ee();i+)if(i % 4 = 3)coutt ii : vBannkNi eendl;elsecoutt ii : vBannkNi;cout enddl nnum) | numm = vBankkN.sizze()cout enndl 輸入錯誤,請請重新輸入:;cout enddl; stringg bankk = vBBankNnum;int caardnumm;strstrream tt;stringg cardd;stringg passsword;stringg tempp;stringg namee;stringg ID;int i;cout namee; cout ID;
19、srand(int)tiime(0);docardnnum=10000+(rrand()%90000);tcaard;while(checkk(cardd);docout passswordd;cout temmp;while(passwword != temmp & cout enndl 前后輸入的的密碼不同,請請重新輸入! eendl);cout enddl;bankcaard bccard(ccard, passwword, bank, namee, ID,0.0);vBankCC.pushh_backk(bcarrd);cout 注冊銀行賬賬號成功! enddl; cout 卡號為:c
20、arrdenndl;void BaankPorrtal:loginnBankCC()stringg carddnum;stringg passsword;unsignned int nuum;docout請輸入要操操作的銀行卡卡號:caardnumm;while(num=matchh(carddnum)=vBaankC.ssize()&couut賬號輸入錯錯誤!enndl);while(true)cout = vBBankCnum.getNaame() 先生/女士= eendl;cout =卡內(nèi)余額共共 vBankkCnumm.gettRemaiinder() RMB= endl;cout =
21、 endll;cout =請選選擇您的操作作:= enndl;cout =1:存款 = enndl;cout =2:取款 = enndl;cout =3:修改銀行卡卡密碼= eendl;cout =4:返回上一級級菜單= eendl;cout = endll eendl;cout SSelectt) | Selecct0 4)coutt 輸入錯誤,請請重新輸入: enndl;selecct=stdd:atooi(Sellect.cc_str();cout enndl;switcch(selecct)casee 1:depposit(num); breeak;casee 2:witthdraww
22、(num);breeak;casee 3:chaangePaassworrd(numm);breeak;casee 4:retturn;defaault:breeak;void BaankPorrtal:depossit(innt num)doublee moneey;cout請輸入您要要存入的金額額:mmoney;vBankCCnum.aaddRemmaindeer(monney);void BaankPorrtal:withddraw(iint num)doublee moneey; couut請輸入您要要取出的金額額:mmoney;if(vBaankCnnum.ggetRemmainde
23、er()=moneyy) vBBankCnum.ssubRemmaindeer(monney);else ccout對不起,余余額不足!=monney) vBBankCindexx.subbRemaiinder(moneyy);returrn true;else rreturnn falsee;void BaankPorrtal:changgePasssword(int num)stringg passsword;stringg tempp;docout請輸入新密密碼:ppasswoord;cout再次確認(rèn)新新密碼:ttemp;while(passwword!=temp&coutt 前后輸入的
24、的密碼不同,請請重新輸入! eendl);vBankCCnum.ssetPassswordd(passsword);int BannkPorttal:mmatch(strinng cardnnum)unsignned int i=0;for(;iivBannkC.siize();i+)if(vBBankCi.geetCarddnum()=carrdnum) reeturn i;returnn i;bool BaankPorrtal:checkk(striing cardnnum)unsignned int i=0;for(;iivBannkC.siize();i+)if(vBBankCi.ge
25、etCarddnum()=carrdnum) reeturn true;returnn falsee;void BaankPorrtal:outpuut()ofstreeam foout(ouutput_file.c_strr();for(unnsigneed int i=0;ivvBankCC.sizee();i+)vBankkCi(fouut);fout.cclose();void BaankPorrtal:bankNNamingg()ifstreeam fiin(bannknamee_filee.c_sttr();stringg inpuut;while(getliine(fiin,in
26、pput)vBankkN.pussh_bacck(inpput);fin.cllose();double BankPPortall:StrrToDouuble(sstringg str, int startt, int end)/把字符串串轉(zhuǎn)化成doouble類類型 int sttate = 0;int i = 0;doublee num = 0;for(; startt cardnnum) carddnum=ccardnuum.subbstr(66); finpasssword; passsword=passwword.ssubstrr(6); finbankkname; bankkname
27、=banknname.ssubstrr(6); finnamee; namee=namee.subsstr(6); finID; ID=IID.subbstr(110); finremaainderrs; rremainnder=SStrToDDoublee(remaainderrs,6,rremainnders.size(); bankkcard bankcc(carddnum,ppasswoord,baanknamme,namme,ID,remaiinder); vBannkC.puush_baack(baankc);fin.cllose();bankNaaming();int Bannk
28、Porttal:MMatch(strinng cardnnum,strinng passwword)unsignned int i=0;for(;iivBannkC.siize();i+)if(vBBankCi.geetCarddnum()=carrdnum&vBannkCi.getPPasswoord()=passsword)retuurn i;returnn i; void BaankPorrtal:Bind() WORRD socckVerssion = MAKEEWORD(2,2); WSAADATA wsaDaata; if(WSASttartupp(sockkVersiion, &
29、wsaDaata)!=0) prinntf(嵌套字未打打開!); returrn; /創(chuàng)創(chuàng)建套接字 SOCCKET sslisteen = ssockett(AF_IINET, SOCK_STREAAM, IPPRROTO_TTCP); if(slistten = INVAALID_SSOCKETT) prinntf(ssockett erroor !); retuurn; /綁綁定IP和端口 socckaddrr_in ssin; sinn.sin_familly = AAF_INEET; sinn.sin_port = htoons(88888); sinn.sin_addr.S_un.S
30、_adddr = IINADDRR_ANY; if(bind(slistten, (LPSOCCKADDRR)&sinn, sizzeof(ssin) = SOOCKET_ERRORR) prinntf(bbind eerror !); /開開始監(jiān)聽 if(listeen(sliisten, 5) = SOCCKET_EERROR) prinntf(llistenn erroor !); retuurn; /循循環(huán)接收數(shù)據(jù)據(jù) SOCCKET ssCliennt; socckaddrr_in rremoteeAddr; intt nAdddrlen = sizzeof(rremoteeAddr)
31、; chaar senndBuf2; chaar recceiveCChoicee2; intt choiice; whiile (truee) prinntf(等待連接.n); sCliient = acceept(sllistenn, (SOOCKADDDR *)&remotteAddrr, &nAAddrleen); if(sClieent = INVAALID_SSOCKETT) printtf(acccept errorr !); contiinue; prinntf(接受到一個個連接:%ss rnn, innet_nttoa(reemoteAAddr.ssin_adddr); re
32、cv(sClieent,reeceiveeChoicce,2,00); /監(jiān)聽選擇 choiice=(rreceivveChoiice0-0); if(choicce=1) chhar reeceiveeCard5; chhar reeceiveePasswword330; reecv(sCClientt,receeiveCaard,5,0); /接受賬號號密碼 reecv(sCClientt,receeivePaassworrd,30,0); sttring cardnnum; caardnumm=receeiveCaard; sttring passwword; paassworrd=re
33、cceivePPasswoord; int inndex; iff(indeex=Mattch(caardnumm,passsword)vBaankC.ssize() spprintff(senddBuf,1); sendd(sCliient,ssendBuuf,strrlen(ssendBuuf)+1,0); /發(fā)送綁定定成功 sprinntf(seendBuff,vBannkCinndex.getBaanknamme().cc_str();/發(fā)送銀行類類型 send(sClieent,seendBuff,strllen(seendBuff)+1,00); ellse spriintf(ss
34、endBuuf,0); sendd(sCliient,ssendBuuf,strrlen(ssendBuuf)+1,0); elsee if(chooice=2) chhar reeceiveeCard5; chhar reeceiveeShoulldpay20; chhar reeceiveePasswword330; intt indeex; reecv(sCClientt,receeiveCaard,5,0); /接受賬號號密碼 reecv(sCClientt,receeivePaassworrd,30,0); strring ccardnuum; carrdnum=receiiveCa
35、rrd; strring ppasswoord; paassworrd=recceivePPasswoord; inddex=Maatch(ccardnuum,passswordd); iff(indexxvBannkC.siize() sprinntf(seendBuff,1); send(sClieent,seendBuff,strllen(seendBuff)+1,00); /發(fā)送驗(yàn)證成成功 recv(sClieent,reeceiveeShoulldpay,20,0); douuble sshoulddpay; shoouldpaay=stdd:atoof(recceiveSShoul
36、ddpay); if(pay(ccardnuum,shoouldpaay) sprinntf(seendBuff,1); seend(sCClientt,senddBuf,sstrlenn(senddBuf)+1,0); /發(fā)送付款款成功 outtput(); elsee ccout余額不足!; ssprinttf(senndBuf,0); seend(sCClientt,senddBuf,sstrlenn(senddBuf)+1,0); /發(fā)送付款款成功 elssespriintf(ssendBuuf,0); send(sClieent,seendBuff,strllen(seendBuff
37、)+1,00); /發(fā)送驗(yàn)證失失敗 closeesockeet(sliisten); WSSACleaanup(); 電商平臺代碼:#ifndeff _ACOOUNT_HH_#definee _ACOUUNT_H_#includde#includde#includde#includde itemm.h#includde bankkcard.husing nnamesppace sstd;class AAccounntprivatee:stringg userrname;stringg passsword;stringg phonnenum;doublee shouuldpayy;int caa
38、rdnumm;public:vectorr vBankk;vectorr vItemm;doublee getSShoulddpay() retuurn shhouldppay;int geetCarddnum()returrn carrdnum;void aaddCarrdnum(int num) carrdnum+=num;void cclshouuldpayy()shoulldpay=0.0;void aaddShoouldpaay(douuble pricee) shoouldpaay+=pricce;void ssubShoouldpaay(douuble pricee) shoou
39、ldpaay-=prrice; Acccount();Accounnt(strring uusernaame,sttring passwword,sstringg phonnenum,vectoor scartt,doubble shhouldppay,innt carrdnum);void ssetPassswordd(striing paassworrd);void ssetPhoone(sttring phoneenum);stringg getUUsernaame();stringg getPPasswoord();stringg getPPhonennum();ofstreeam&
40、ooperattor (ofsttream& ofs);#endif#ifndeff _BANNKCARDD_H_#definee _BANKKCARD_H_#includde#includdeusing nnamesppace sstd;class bbankcaardprivatte: striing caardnumm; striing baanknamme; publicc: bankkcard() bankkcard(strinng cardnnum,strinng banknname) thiis-caardnumm=carddnum; thiis-baanknamme=bannk
41、namee; striing geetCarddnum() reeturn cardnnum; sstringg getBBanknaame() reeturn banknname; ;#endif#ifndeff _GOOODS_H_#definee _GOODDS_H_#includde#includdeusing nnamesppace sstd;/登錄后,11.查看現(xiàn)有有商品1.查看哪一類類商品(記得得顯示產(chǎn)品描描述,產(chǎn)品原原價,產(chǎn)品剩剩余量,優(yōu)惠惠信息)|2.回退class ggoodsprotectted:stringg namee;stringg desccriptiion;do
42、ublee origginalPPrice;int reemaindder;doublee disccount;/折扣public:goods()goods(strinng name,strinng descrriptioon,doublle origiinalPrrice,int remaiinder,doublle discoount) thiss-namme=namme; thiss-desscripttion=ddescriiptionn; thiss-oriiginallPricee=origginalPPrice; thiss-remmaindeer=remmaindeer; th
43、iss-disscountt=disccount; stringg getNName();stringg getDDescriiptionn();doublee getOOriginnalPriice();int geetRemaainderr();bool ssubRemmaindeer(intt num)if(reemaindder=nnum)remaainderr=remaainderr-num;retuurn true;returrn falsee;doublee getDDiscouunt();virtuaal doublle gettPricee()returrn disscoun
44、tt*origginalPPrice;ofstreeam& goodds:opperatoor (ofstrream& ofs);class ffood : publlic goodsspublic:virtuaal doublle gettPricee();food(sstringg name,strinng descrriptioon,doublle origiinalPrrice,int remaiinder,doublle discoount):goodss(name,descrriptioon,origiinalPrrice,remaiinder,discoount);class c
45、clothiing : publiic goodsspublic:virtuaal doublle gettPricee();clothiing(sttring name,strinng descrriptioon,doublle origiinalPrrice,int remaiinder,doublle discoount):goodss(name,descrriptioon,origiinalPrrice,remaiinder,discoount);class bbook : publlic goodsspublic:virtuaal doublle gettPricee();book(
46、sstringg name,strinng descrriptioon,doublle origiinalPrrice,int remaiinder,doublle discoount):goodss(name,descrriptioon,origiinalPrrice,remaiinder,discoount);#endif#ifndeff _ITEEM_H_#definee _ITEMM_H_#includdeusing nnamesppace sstd;class iitemprotectted:stringg namee;int nuum;doublee pricce;public:i
47、tem(sstringg name,int num,doublle pricee) thhis-nname=nname;this-num=num;this-pricce=priice;stringg getNName() retuurn naame;int geetNum() retuurn nuum;doublee getPPrice()returrn priice;#endif#ifndeff _PLAATFORMM_H_#definee _PLATTFORM_H_#includde #includde #pragmaa commeent(lib,ws2_32.liib) #includd
48、e #includde #includde Accoount.hh#includde goodds.husing sstd:vvectorr;class PPlatfoormprivatee:vectorr vvAccouunt;vectorr vFoodd;vectorr vClotthing;vectorr vBookk;void iinit();/初始化void rregistterAcccount();bool lloginAAccounnt();/voidd channgePhoone(sttring phoneenum);void ooutputt();bool ccheck(st
49、rinng useernamee);int maatch(sstringg userrname,strinng passswordd);void ccheckggoods(int acccountt);doublee StrTToDoubble(sttring str, int sttart, int ennd);bool aaddshooppinggcart(int chhoice,int inndex,iint nuum,intt accoount);void ccheckSScart(int acccountt);void BBand(iint inndex,sstringg cardd
50、num,sstringg passsword);bool PPay(innt inddex,sttring card);public:Platfoorm();#endif#includde Accoount.hhusing sstd:sstringg;Accountt:Accoount(sstringg usernname,strinng passwword,strinng phoneenum,vectoor scartt,doublle shoulldpay,int cardnnum)this-usernname=uusernaame;this-passwword=ppasswoord;th
51、is-phoneenum=pphonennum;this-vItemm=scarrt;this-shoulldpay=shoulldpay;this-cardnnum=caardnumm;void Acccountt:settPasswword(sstringg passwword)this-passwword=ppasswoord;void Acccountt:settPhonee(striing phoneenum)this-phoneenum=pphonennum;string Accouunt:ggetUseernamee()returnn userrname;string Accou
52、unt:ggetPassswordd()returnn passsword;string Accouunt:ggetPhoonenumm()returnn phonnenum;ofstreaam& Accoount:operaator (ofsstreamm& ofs)ofs 用戶名:useernamee;ofs 密碼:passswordd;ofs 手機(jī)號:phoonenumm;ofs 銀行卡數(shù)數(shù)量:carrdnumendll;/ofs 購物物車:;/for(unsiggned ii=0;iscartt.getvvItem().sizze();ii+)/ofssscaart.geetvItee
53、m()ii.gettName() sccart.ggetvIttem()i.geetnum() sccart.ggetvIttem()i.geetPricce()endl;/returnn ofs;#includde goodds.husing sstd:sstringg;/goodss:gooods(sttring name,strinng desscripttion,ddoublee origginalPPrice,int rremainnder,ddoublee disccount)string goodss:gettName() retturn nname;string goodss:
54、gettDescrriptioon()returnn desccriptiion;double goodss:gettOrigiinalPrrice()returnn origginalPPrice;int gooods:ggetRemmaindeer()returnn remaainderr;double goodss:gettDiscoount()returnn disccount;double food:getPrrice()returnn disccount*origiinalPrrice;double clothhing:getPrrice()returnn disccount*or
55、igiinalPrrice;double book:getPrrice()returnn disccount*origiinalPrrice;ofstreaam& goodds:opperatoor (ofstrream& ofs)ofs 名稱:namme;ofs 描述:desscripttion;ofs 原價:oriiginallPricee;ofs 剩余量:remmaindeer;ofs 折扣:disscounttenddl;returnn ofs;#includde Plattform.h#includde #includde #includde const sstringg Accoo
56、unt_ffile = Acccount.txt;const sstringg goodds_fille=gooods.ttxt;const sstringg bankkcard_file = baankcarrd.txtt;Platforrm:Pllatforrm()/登錄前,登登錄注冊退出出init();while(true)cout enndl;cout =歡歡迎來到MYY電商平臺= eendl;cout = endl;cout =您想進(jìn)行行什么操作?= endll;cout =1:登錄錄賬號 = endll;cout =2:注冊冊賬號 = endll;cout =3:退出出 = enn
57、dl;cout = endl enddl;cout SSelectt) | Selecct0 3)coutt 輸入錯誤,請請重新輸入: enndl;cout enndl; selecct=stdd:atooi(Sellect.cc_str();switcch(selecct)casee 1:if(!logiinAccoount()coout輸入密碼超次數(shù)限限制!enddl;breeak;casee 2:reggisterrAccouunt();breeak;casee 3:outtput();retturn;defaault:breeak;double Platfform:StrTooDoub
58、lle(strring str, int startt, int end)/把字符串串轉(zhuǎn)化成doouble類類型 int sttate = 0;int i = 0;doublee num = 0;for(; startt endd; +sttart)if(sttate = 0 & strrstartt != . & isdiigit(sstrstartt)num = numm * 100 + sttrstartt - 00;else if(staate = 0 & strstartt = .)statte = 11;else if(staate = 1 & isdiigit(sstrstart
59、t)num = numm * 100 + sttrstartt - 00;+i;returnn num/pow(110, i);void Pllatforrm:innit()ifstreeam fiin(Acccount_file.c_strr();stringg userrname;stringg passsword;stringg phonnenum;vectorr scartt;stringg carddnums;int caardnumm;while(finusernname)usernname=uusernaame.suubstr(8);finpasswword;passwword=
60、ppasswoord.suubstr(6);finphoneenum;phoneenum=pphonennum.suubstr(8);fincardnnums;cardnnums=ccardnuums.suubstr(12);cardnnum=sttd:attoi(caardnumms.c_sstr();Accouunt accouunt(ussernamme,passswordd,phonnenum,scartt,0.0,cardnnum);vAccoount.ppush_bback(aaccounnt);fin.cllose();ifstreeam fiingoodd(goodds_fil
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 異地貸款備案管理辦法
- 外聘培訓(xùn)機(jī)構(gòu)管理辦法
- 肺功能檢查護(hù)理課件
- 肯德基兒童畫課件
- 肥胖中醫(yī)課件
- 店鋪陳列培訓(xùn)課件
- 肝膽中醫(yī)課件
- 高新一中八上數(shù)學(xué)試卷
- 東莞中考經(jīng)典數(shù)學(xué)試卷
- 封面白色的數(shù)學(xué)試卷
- 藥品GMP新規(guī)與藥用輔料包材管理培訓(xùn)課件
- 護(hù)士循證決策能力量表漢化及信效度評價
- 2025春新版三年級下冊科學(xué)?必背知識點(diǎn)考點(diǎn)
- 小學(xué)信息化培訓(xùn):AI賦能教學(xué)與教師能力提升
- 腫瘤病人的心理特點(diǎn)與心理護(hù)理
- 2024年河北省物理組招生計(jì)劃
- 培土路肩施工方案
- 雷雨劇本文件完整版電子書下載
- 裝修代賣合同
- 夫妻代理訴訟授權(quán)委托書
- 個人生意入股合同范本
評論
0/150
提交評論