北郵C銀行門戶與電商平臺(tái)_第1頁
北郵C銀行門戶與電商平臺(tái)_第2頁
北郵C銀行門戶與電商平臺(tái)_第3頁
北郵C銀行門戶與電商平臺(tái)_第4頁
北郵C銀行門戶與電商平臺(tái)_第5頁
已閱讀5頁,還剩71頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、C+電商交易平臺(tái)設(shè)計(jì)班級(jí):2013211306 姓名:嚴(yán)浩 學(xué) 號(hào):2013211321實(shí)驗(yàn)?zāi)康腻憻捨覀冇胏+編程的能能力培養(yǎng)我們考慮問問題是否全面面的能力訓(xùn)練我們的代碼碼優(yōu)化能力基本內(nèi)容題目一:銀行門門戶的設(shè)計(jì)該門戶是一個(gè)個(gè)單獨(dú)的程序序,程序要求求至少支持以以下功能:注冊(cè)銀行卡,銀銀行可選;修改銀行卡密碼碼;存款取款;銀行卡至少需要要有卡號(hào),密密碼,所屬銀銀行名稱,持持卡人身份證證號(hào),卡內(nèi)金金額等內(nèi)容。要求1:請(qǐng)把所所有的銀行名名寫入文件(或或數(shù)據(jù)庫(kù)),注注冊(cè)銀行卡的的時(shí)候,要求求只能選擇已已經(jīng)存在的銀銀行進(jìn)行注冊(cè)冊(cè)。要求2:請(qǐng)做好好錯(cuò)誤場(chǎng)景的的處理,例如如讀銀行文件錯(cuò)錯(cuò)誤,輸入數(shù)數(shù)據(jù)不合法

2、等等等。題目二:電商平平臺(tái)的設(shè)計(jì)該平臺(tái)是銀行行門戶之外的的一個(gè)單獨(dú)的的程序,程序序要求至少支支持以下功能能:注冊(cè)&登錄:支支持新用戶注注冊(cè)平臺(tái)賬號(hào)號(hào),已注冊(cè)用用戶用平臺(tái)賬賬號(hào)登錄平臺(tái)臺(tái)。(要求已已注冊(cè)用戶的的信息長(zhǎng)久保保留。)瀏覽平臺(tái)產(chǎn)品信信息。優(yōu)惠活動(dòng):支持持對(duì)同一品類類下所有產(chǎn)品品打折的活動(dòng)動(dòng),支持單筆筆訂單滿X減減Y的活動(dòng)。購(gòu)買產(chǎn)品:支持持用戶添加產(chǎn)產(chǎn)品到購(gòu)物車車,查看實(shí)際際應(yīng)付的產(chǎn)品品價(jià)格,提交交訂單。在題目二我們暫暫時(shí)不考慮提提交訂單后支支付等后續(xù)需需求。要求1:電商平平臺(tái)上至少有有三類產(chǎn)品:如食物、服服裝、圖書等等,每類產(chǎn)品品中至少有三三個(gè)具體的產(chǎn)產(chǎn)品(如圖書書中可以有CC+ Pr

3、rimer、EEfferttive CC+等),每每個(gè)具體的產(chǎn)產(chǎn)品請(qǐng)至少包包含產(chǎn)品描述述,產(chǎn)品原價(jià)價(jià),產(chǎn)品剩余余量等數(shù)據(jù)。所所有的產(chǎn)品信信息需要存儲(chǔ)儲(chǔ)在數(shù)據(jù)庫(kù)或或文件中,不不能寫在代碼碼中,平臺(tái)管管理員通過直直接修改數(shù)據(jù)據(jù)庫(kù)或文件,管管理本平臺(tái)上上的產(chǎn)品,包包括產(chǎn)品的增增加和刪除,修修改數(shù)量以及及具體產(chǎn)品的的屬性信息等等。要求2:請(qǐng)至少少設(shè)計(jì)一層繼繼承體系(產(chǎn)產(chǎn)品基類-產(chǎn)產(chǎn)品子類),設(shè)設(shè)計(jì)一個(gè)產(chǎn)品品基類,然后后讓圖書類、電電子產(chǎn)品類和和服裝類等產(chǎn)產(chǎn)品子類類繼繼承它,具體體的產(chǎn)品是產(chǎn)產(chǎn)品子類的實(shí)實(shí)例對(duì)象( 是圖書類類的實(shí)例對(duì)象象) 。產(chǎn)品品基類請(qǐng)至少具具有一個(gè)虛函函數(shù)getPPrice()用于計(jì)

4、算算具體產(chǎn)品的的價(jià)格。要求3:請(qǐng)通過過為每個(gè)產(chǎn)品品子類定義“品品類折扣系數(shù)數(shù)”來支持對(duì)對(duì)同產(chǎn)品子類類下所有產(chǎn)品品打折扣的活活動(dòng)(如圖書書全場(chǎng)5折,則則圖書類這一一產(chǎn)品子類的的折扣系數(shù)為為0.5)。要求4:請(qǐng)做好好錯(cuò)誤場(chǎng)景的的處理。題目三:網(wǎng)上支支付的設(shè)計(jì)實(shí)現(xiàn)題目三會(huì)讓讓你設(shè)計(jì)的平平臺(tái)像個(gè)真正正的運(yùn)行在網(wǎng)網(wǎng)絡(luò)上的平臺(tái)臺(tái)。題目三要要求在題目一一、二的基礎(chǔ)礎(chǔ)上支持通過過網(wǎng)上支付在在電商平臺(tái)上上購(gòu)物,請(qǐng)至至少實(shí)現(xiàn)以下下功能:綁定銀行卡:支支持電商平臺(tái)臺(tái)賬號(hào)綁定銀銀行卡。同一一賬號(hào)可以綁綁定多張銀行行卡,而且銀銀行卡可以屬屬于不同銀行行。網(wǎng)上支付:選擇擇綁定的任一一銀行卡支付付電商平臺(tái)上上的訂單。要求1

5、:綁定銀銀行卡和選擇擇銀行卡進(jìn)行行支付時(shí)都要要求提供對(duì)應(yīng)應(yīng)的銀行卡密密碼。要求2:當(dāng)在電電商平臺(tái)上綁綁定銀行卡或或者進(jìn)行網(wǎng)上上支付的時(shí)候候,請(qǐng)不要直直接打開某個(gè)個(gè)文件查找銀銀行卡的信息息,因?yàn)殂y行行卡信息文件件是銀行門戶戶系統(tǒng)私有的的,電商平臺(tái)臺(tái)系統(tǒng)無法直直接訪問,而而應(yīng)該由電商商平臺(tái)系統(tǒng)去去向銀行門戶戶系統(tǒng)對(duì)接數(shù)數(shù)據(jù)。請(qǐng)用ssockett通信來傳送送數(shù)據(jù)。要求3:請(qǐng)做好好錯(cuò)誤場(chǎng)景的的處理,如綁綁定銀行卡失失敗,支付失失敗等。實(shí)驗(yàn)方法題目一:創(chuàng)建了銀行卡類類、銀行門戶類類,銀行卡里里包含了卡號(hào)號(hào)、姓名、密密碼、身份證證號(hào)、銀行名名稱、余額幾幾個(gè)屬性。銀行門戶有操作作銀行卡,注注冊(cè)銀行卡兩兩個(gè)功

6、能,操操作銀行卡又又包括存取款款,修改密碼碼等功能,賬賬戶信息和銀銀行名稱保存存在文件里,銀銀行卡用veector類類型保存。題目二:創(chuàng)建了電商平臺(tái)臺(tái)類、賬戶類類、商品類(商商品類有3個(gè)派生類)、綁定銀行卡類、購(gòu)物車項(xiàng)目類。其中賬戶類中包含了用戶名、密碼、手機(jī)號(hào)、購(gòu)物車、應(yīng)付款、綁定銀行卡、綁定銀行卡數(shù)量這幾個(gè)屬性,其中購(gòu)物車?yán)锏捻?xiàng)目用vector類型保存。電商平臺(tái)中的賬賬戶也用veector類類型保存,平平臺(tái)的功能有有:登錄、注注冊(cè),登錄后后可以綁定銀銀行卡、查看看商品并添加加購(gòu)物車、查查看購(gòu)物車和和應(yīng)付金額、結(jié)結(jié)算購(gòu)物車、退退出登錄等功功能。題目三:在綁定銀行卡和和付款時(shí)用ssockett

7、通信來傳送送數(shù)據(jù)。綁定銀行卡時(shí),先先向銀行門戶戶發(fā)送綁定銀銀行卡標(biāo)志位位表示綁定功功能,然后發(fā)發(fā)送卡號(hào)密碼碼,驗(yàn)證通過過后返回成功功標(biāo)志位,電電商平臺(tái)收到到后綁定成功功。付款時(shí),先向銀銀行門戶發(fā)送送付款標(biāo)志位位表示付款功功能,然后后發(fā)送卡號(hào)密密碼,驗(yàn)證通通過后返回成成功標(biāo)志位,電電商平臺(tái)收到到后發(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 卡號(hào):carrdnum;ofs 密碼:passswordd;ofs 銀行:bannknamee;ofs 姓名:namme;ofs 身份證號(hào)號(hào):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 輸入錯(cuò)誤,請(qǐng)請(qǐng)重新輸入: 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:注冊(cè)冊(cè)銀行卡 = endl;cout =3:退出出 = enndl;cout = endl enddl;cout SSelectt) | Se

17、lecct0 3)coutt 輸入錯(cuò)誤,請(qǐng)請(qǐng)重新輸入: 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 請(qǐng)選擇你要要注冊(cè)的銀行行: 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 輸入錯(cuò)誤,請(qǐng)請(qǐng)重新輸入:;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 前后輸入的的密碼不同,請(qǐng)請(qǐng)重新輸入! eendl);cout enddl;bankcaard bccard(ccard, passwword, bank, namee, ID,0.0);vBankCC.pushh_backk(bcarrd);cout 注冊(cè)銀行賬賬號(hào)成功! enddl; cout 卡號(hào)為:c

20、arrdenndl;void BaankPorrtal:loginnBankCC()stringg carddnum;stringg passsword;unsignned int nuum;docout請(qǐng)輸入要操操作的銀行卡卡號(hào):caardnumm;while(num=matchh(carddnum)=vBaankC.ssize()&couut賬號(hào)輸入錯(cuò)錯(cuò)誤!enndl);while(true)cout = vBBankCnum.getNaame() 先生/女士= eendl;cout =卡內(nèi)余額共共 vBankkCnumm.gettRemaiinder() RMB= endl;cout =

21、 endll;cout =請(qǐng)選選擇您的操作作:= enndl;cout =1:存款 = enndl;cout =2:取款 = enndl;cout =3:修改銀行卡卡密碼= eendl;cout =4:返回上一級(jí)級(jí)菜單= eendl;cout = endll eendl;cout SSelectt) | Selecct0 4)coutt 輸入錯(cuò)誤,請(qǐng)請(qǐng)重新輸入: 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請(qǐng)輸入您要要存入的金額額:mmoney;vBankCCnum.aaddRemmaindeer(monney);void BaankPorrtal:withddraw(iint num)doublee moneey; couut請(qǐng)輸入您要要取出的金額額:mmoney;if(vBaankCnnum.ggetRemmainde

23、er()=moneyy) vBBankCnum.ssubRemmaindeer(monney);else ccout對(duì)不起,余余額不足!=monney) vBBankCindexx.subbRemaiinder(moneyy);returrn true;else rreturnn falsee;void BaankPorrtal:changgePasssword(int num)stringg passsword;stringg tempp;docout請(qǐng)輸入新密密碼:ppasswoord;cout再次確認(rèn)新新密碼:ttemp;while(passwword!=temp&coutt 前后輸入的

24、的密碼不同,請(qǐng)請(qǐng)重新輸入! 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(接受到一個(gè)個(gè)連接:%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); /接受賬號(hào)號(hào)密碼 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); /接受賬號(hào)號(hào)密碼 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(); 電商平臺(tái)代碼:#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)品原原價(jià),產(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ī)號(hào):phoonenumm;ofs 銀行卡數(shù)數(shù)量:carrdnumendll;/ofs 購(gòu)物物車:;/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 原價(jià):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()/登錄前,登登錄注冊(cè)退出出init();while(true)cout enndl;cout =歡歡迎來到MYY電商平臺(tái)= eendl;cout = endl;cout =您想進(jìn)行行什么操作?= endll;cout =1:登錄錄賬號(hào) = endll;cout =2:注冊(cè)冊(cè)賬號(hào) = endll;cout =3:退出出 = enn

57、dl;cout = endl enddl;cout SSelectt) | Selecct0 3)coutt 輸入錯(cuò)誤,請(qǐng)請(qǐng)重新輸入: 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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論