当前位置:首页 >> 信息与通信 >>

部分代码


辛苦您了,谢谢! 辛苦您了,谢谢!
CAdminAccount.h 文件 #pragma once #include "IAdminAccount.h" #include "IBank.h" class CAdminAccount : public IAdminAccount { public: CAdminAccount(IBank* b, const _tstring& aid,const _tstring& p) : Bank(b), AccountID(aid), Password(p) { } virtual ~CAdminAccount(void) { } //匹配账户 id virtual bool isIDEqual(const _tstring& aid) const { return (AccountID == aid); } //匹配账户密码 virtual bool isPWDEqual(const _tstring& pwd) const { return (Password == pwd); } //获取账户 id virtual const _tstring& getAccountID() const { return AccountID; } //设置密码 virtual void setPassword(const _tstring& pwd) { Password = pwd; } //获取账户类型 virtual _tstring getAccountType() const { return ADMINISTRATOR_TIP[Langue]; }

辛苦您了,谢谢! 辛苦您了,谢谢!
//获取全部可用的信息 virtual _tstring getAllInfo() const { return (ACC_TYPE_TIP[Langue] + getAccountType() + NEXT_LINE + ACC_TYPE_TIP[Langue] + AccountID); } //根据 id 查找账户 virtual IAccount* queryAccount(const _tstring& aid) { return Bank->queryAccount(aid); } //添加账户 virtual INormalAccount* addAccount(IAccountInfo* ai, IUserInfo* ui) { return Bank->addAccount(ai, ui); } //添加共享账户 virtual INormalAccount* addShareAccount(INormalAccount* nacc) { return Bank->addShareAccount(nacc); } private: //管理员操纵的银行 IBank* Bank; //账户 id _tstring AccountID; //账户密码 _tstring Password; };

CAdminManipulator.h 文件 #pragma once #include "IAdminAccount.h" #include "CManipulator.h" #include "CDebitAccInfo.h" #include "CUserInfo.h" #include "CNormalAccount.h"

辛苦您了,谢谢! 辛苦您了,谢谢!
class CAdminManipulator : public CManipulator { public: CAdminManipulator(IAdminAccount* admin, IDispenser* disp , IManipulator* m=NULL) : CManipulator(disp, m), Admin(admin) { } virtual ~CAdminManipulator(void) { } //设置服务请求者 virtual void setRequester(IAccount* acc) { IAdminAccount* admin = NULL; admin = dynamic_cast<IAdminAccount*>(acc); if (admin == NULL) { throw CMyException(unknow_error, UNKNOW_ERROR[Langue]); } Admin = admin; } //处理请求 virtual void handle() { //重置处理状态 isFinished = false; CUI->screenClean(); CUI->screenColor("0C"); int ch = 0; while (!isFinished) { try { //显示菜单 diplayMenu(); //用户选择操作 ch = CUI->selectionBox(CHOICE_TIP[Langue], 4); //处理用户请求 processEvent(ch); } catch(CMyException err) {

辛苦您了,谢谢! 辛苦您了,谢谢!
CUI->messageBox(VOID_TSTRING, err.what()); CUI->screenHold(); } } CUI->screenColor("07"); } protected: //显示菜单 void diplayMenu() { CUI->messageBox(ACC_TYPE_TIP[Langue] + Admin->getAccountType(), ADMIN_MENU[Langue], -2); } //处理用户请求 void processEvent(unsigned int ch) { switch (ch) { case 1: createDebitAccount(); break; case 2: createDuplicateAccount(); break; case 3: queryAccount(); break; case 4: stopATM(); break; case 0: stop(); break; default: throw CMyException(choice_illegal, CHOICE_ILLEGAL[Langue]); } } //创建借记账户 void createDebitAccount() { ICash* cash = NULL; _tstring fname(VOID_TSTRING); _tstring lname(VOID_TSTRING);

辛苦您了,谢谢! 辛苦您了,谢谢!
_tstring idno(VOID_TSTRING); _tstring pwd(VOID_TSTRING); _tstring rpwd(VOID_TSTRING); _tstring bln(VOID_TSTRING); int state = 0; bool isComplete = false; CUI->messageBox(VOID_TSTRING, CREATE_DEBIT_ACC_TITLE[Langue]); while (!isComplete) { try { switch (state) { case 0: { fname = CUI->lineBox(FIRST_NAME_TIP[Langue]); TypeCheck->isUserName(fname); state = 1; } case 1: { lname = CUI->lineBox(LAST_NAME_TIP[Langue]); TypeCheck->isUserName(lname); state = 2; } case 2: { idno = CUI->lineBox(ID_NUMBER_TIP[Langue]); TypeCheck->isIDNumber(idno); state = 3; } case 3: { if (CUI->acknowledgeBox(CURRENCY_SEL_TIP[Langue], 'r', 'd')) { bln = CUI->lineBox(BALANCE_CNY_TIP[Langue]); TypeCheck->isBalance(bln); cash = new CRenminbi(_tstof(bln.c_str())); } else { bln = CUI->lineBox(BALANCE_DOLS_TIP[Langue]); TypeCheck->isBalance(bln); cash = new CDollar(_tstof(bln.c_str())); } state = 4; } case 4:

辛苦您了,谢谢! 辛苦您了,谢谢!
{ pwd = CUI->passwordBox(PASSWORD_TIP[Langue]); TypeCheck->isPassword(pwd); rpwd = CUI->passwordBox(RE_ENTER_PWD_TIP[Langue]); TypeCheck->isPassword(rpwd); if (pwd != rpwd) { throw CMyException(password_conflicting, PASSWORD_CONFLICTING[Langue]); } isComplete = true; state = 0; } default: ; } IAccountInfo* ai = new CDebitAccInfo(pwd, cash); IUserInfo* ui = new CUserInfo(fname, lname, idno); INormalAccount* nuser = Admin->addAccount(ai, ui); CUI->messageBox(VOID_TSTRING, nuser->getAllInfo()); CUI->screenHold(); } catch (CMyException err) { CUI->messageBox(VOID_TSTRING, err.what()); if (!CUI->acknowledgeBox(TRY_AGAIN_TIP[Langue])) { isComplete = true; } else { isComplete = false; } } } } //创建副卡账户 void createDuplicateAccount() { _tstring aid(VOID_TSTRING); CUI->messageBox(VOID_TSTRING, CREATE_DUPL_ACC_TIP[Langue]); aid = CUI->textBox(ACCOUNT_ID_TIP[Langue]); TypeCheck->isAccountID(aid); IAccount* acc = Admin->queryAccount(aid); INormalAccount* nacc = dynamic_cast<INormalAccount*>(acc); if (nacc == NULL) { throw CMyException(user_not_exist,

辛苦您了,谢谢! 辛苦您了,谢谢!
USER_NOT_EXIST[Langue]); } INormalAccount* sacc = Admin->addShareAccount(nacc); CUI->messageBox(VOID_TSTRING, sacc->getAllInfo()); CUI->screenHold(); } //查询账户 void queryAccount() { _tstring aid(VOID_TSTRING); CUI->messageBox(VOID_TSTRING, QUERY_ACC_TIP[Langue]); aid = CUI->textBox(ACCOUNT_ID_TIP[Langue]); TypeCheck->isAccountID(aid); IAccount* acc = Admin->queryAccount(aid); INormalAccount* nuser = dynamic_cast<INormalAccount*>(acc); if (nuser == NULL) { throw CMyException(user_not_exist, USER_NOT_EXIST[Langue]); } CUI->messageBox(VOID_TSTRING, nuser->getAllInfo()); CUI->screenHold(); } //停止 ATM 机 void stopATM() { if (CUI->acknowledgeBox(STOP_ATM_TIP[Langue])){ Dispenser->poweroff(); } } private: //进行操作的管理员 IAdminAccount* Admin; };

辛苦您了,谢谢! 辛苦您了,谢谢!
CBank.h 文件 #pragma once #include <list> using namespace std; #include "charsetdef.h" #include "IBank.h" #include "CDebitAccount.h" #include "CAdminAccount.h" #include "CDuplicateAccount.h" #include "CMyException.h" typedef list<IAccount*> IAccountList; class CBank : public IBank { public: CBank(void) : AutoAccountID(100100100) { } virtual ~CBank(void) { } //根据 id 查找账户 virtual IAccount* queryAccount(const _tstring& aid) { IAccountList::iterator itr = AccountList.begin(); for (; itr != AccountList.end(); ++itr) { if ((*itr)->isIDEqual(aid)) { return (*itr); } } throw CMyException(user_not_exist, USER_NOT_EXIST[Langue]); } //添加借记账户账户 virtual INormalAccount* addAccount(IAccountInfo* ai, IUserInfo* ui) {

辛苦您了,谢谢! 辛苦您了,谢谢!
INormalAccount* account = new CDebitAccount(generateID(), ai, ui); AccountList.push_back(account); return account; } //添加共享账户 virtual INormalAccount* addShareAccount(INormalAccount* nacc) { CDuplicateAccount* dacc = NULL; dacc = dynamic_cast<CDuplicateAccount*>(nacc); if (dacc != NULL) { throw CMyException(dupl_acc_conflicting, DUPL_ACC_CONFLICTING[Langue]); } INormalAccount* account = NULL; try { account = new CDuplicateAccount(generateID(), nacc); AccountList.push_back(account); return account; } catch (CMyException err) { delete account; throw CMyException(dupl_acc_amount_limit, DUPL_ACC_AMOUNT_LIMIT[Langue]); } } //添加管理员 virtual IAdminAccount* addAdministrator(const _tstring& p) { IAdminAccount* admin = new CAdminAccount(this, generateID(), p); AccountList.push_back(admin); return admin; } private: _tstring generateID() { TCHAR buf[32]; _stprintf(buf, _T("%ld"), AutoAccountID++); return buf; } private: //自动账户 id unsigned long AutoAccountID;

辛苦您了,谢谢! 辛苦您了,谢谢!
//存储所有银行账户 IAccountList AccountList; }; CCash.h 文件 #pragma once #include <iostream> #include "ICash.h" #include "FloatOperation.h" using namespace std; class CCash : public ICash { public: CCash(const double& c) : Cash(c > 0.0? c: 0.0) { } virtual ~CCash(void) { } //货币加法运算 virtual void plus(ICash* cash) { if (cash == NULL) { return; } ICash* inter = toInternal(cash); Cash += inter->getCash(); delete inter; } //货币减法运算 virtual void minus(ICash* cash) { if (cash == NULL) { return; } ICash* inter = toInternal(cash); Cash -= inter->getCash();

辛苦您了,谢谢! 辛苦您了,谢谢!
delete inter; } //货币比较运算 virtual int compare(ICash* cash=NULL) const { double money = 0.0; if (cash != NULL) { ICash* inter = toInternal(cash); money = inter->getCash(); delete inter; } if (isEqual(Cash, money)) { return 0; } else if (Cash > money) { return 1; } else { return -1; } } //获取当前货币数量 virtual const double& getCash() const { return Cash; } //获取货币信息加货币数量 virtual _tstring getCashInfo() const { TCHAR buf[32]; _stprintf(buf, _T("%s%0.2lf"), getCurrencyInfo().c_str(), Cash); return buf; } protected: //持有本种货币的数量 double Cash; };

CCreditAccount.h 文件 #pragma once #include "CNormalAccount.h"

辛苦您了,谢谢! 辛苦您了,谢谢!
class CCreditAccount : public CNormalAccount { public: CCreditAccount(const _tstring& aid, IAccountInfo* ai, IUserInfo* ui) : CNormalAccount(aid, ai, ui) { } virtual ~CCreditAccount(void) { } //获取账户行为操纵类 virtual ICard* getCard() const { } //获取账户类型 virtual _tstring getAccountType() const { return CREDIT_ACC_TIP[Langue]; } };

CCreditCard.h 文件 #pragma once #include "ICard.h" class CCreditCard : public ICard { public: CCreditCard(void) { } virtual ~CCreditCard(void) { } //取款 virtual void withdrawal(const double& b) { } //存款

辛苦您了,谢谢! 辛苦您了,谢谢!
virtual void deposit(const double& b) { } //转账 virtual void transfer(IBank* bk, const unsigned long& id, const double& b) { } //查询余额 virtual const double& getBalance() const { } //更改密码 virtual void changePassword(const _tstring& oldpwd, const _tstring& newpwd) { } };

CCUI.h 文件 #pragma once #include <conio.h> #include "charsetdef.h" #include "CTypeCheck.h" #include "ICUI.h" #include "CMyException.h" #define MAX_LINE_WIDTH 78 class CCUI : public ICUI { public: //文本框 virtual _tstring textBox(const _tstring& tip) const { try { _tstring text(VOID_TSTRING); _tcout << tip; flush(); _tcin >> text; _tcin.exceptions(_tios::badbit | _tios::failbit | _tios::eofbit); return text; } catch (_tios::failure err) {

辛苦您了,谢谢! 辛苦您了,谢谢!
clear(); throw CMyException(input_illegal, INPUT_ILLEGAL[Langue]); } } //行级文本文本框 virtual _tstring lineBox(const _tstring& tip) const { try { _tstring text(VOID_TSTRING); _tcout << tip; flush(); getline(_tcin, text); _tcin.exceptions(_tios::badbit | _tios::failbit | _tios::eofbit); return text; } catch (_tios::failure err) { clear(); throw CMyException(input_illegal, INPUT_ILLEGAL[Langue]); } } //确认框 virtual bool acknowledgeBox(const _tstring& tip, const TCHAR yes='y', const TCHAR no='n') const { try { int ch = 0; while (true) { _tcout << tip; flush(); do { ch = _getch(); } while (!isprint(ch)); _tcout << static_cast<TCHAR>(ch)<< endl; if (ch == no) { return false; } else if (ch == yes) { return true; } } } catch (_tios::failure err) { clear(); throw CMyException(input_illegal, INPUT_ILLEGAL[Langue]);

辛苦您了,谢谢! 辛苦您了,谢谢!
} } //选择框 virtual int selectionBox(const _tstring& tip, const int max, const int min=0) const { int isel = 0; try { _tstring sel = lineBox(tip); ITypeCheck* tc = new CTypeCheck(); tc->isInteger(sel); isel = _ttoi(sel.c_str()); delete tc; } catch (CMyException err) { throw CMyException(choice_illegal, CHOICE_ILLEGAL[Langue]); } if (isel < min || isel > max) { throw CMyException(choice_illegal, CHOICE_ILLEGAL[Langue]); } return isel; } //密码框 virtual _tstring passwordBox(const _tstring& tip) const { try { _tstring pwd(VOID_TSTRING); _tcout << tip; for (int ch = 0; ch != '\r';) { ch = _getch(); if (ch <= 256 && isalnum(ch)) { pwd.push_back(static_cast<char>(ch)); } else if (ch == '\b' && !pwd.empty()) { pwd.erase(pwd.end()-1); } } _tcout << endl; return pwd; } catch (_tios::failure err) { clear(); throw CMyException(input_illegal, INPUT_ILLEGAL[Langue]); }

辛苦您了,谢谢! 辛苦您了,谢谢!
} //保持屏幕 virtual void screenHold(const _tstring& tip=VOID_TSTRING) const { try { _tcout << tip; _getch(); } catch (_tios::failure err) { clear(); throw CMyException(input_illegal, INPUT_ILLEGAL[Langue]); } } //屏幕颜色 virtual void screenColor(const string& color) const { system(("COLOR "+color).c_str()); } //清屏 virtual void screenClean() const { system("CLS"); } //消息盒子 virtual void messageBox(const _tstring& title, const _tstring& tip, int align=-1) const { try { _tstring ftitle(title); _tcout.width(MAX_LINE_WIDTH); _tcout.fill('-'); _tcout << VOID_TSTRING<< endl; if (ftitle != VOID_TSTRING) { if (align <= -2) { align = putLine(ftitle); } else { putLine(ftitle, align); } } divideLine(tip, align); _tcout.width(MAX_LINE_WIDTH); _tcout.fill('-'); _tcout << VOID_TSTRING<< endl; } catch (_tios::failure err) { clear();

辛苦您了,谢谢! 辛苦您了,谢谢!
throw CMyException(input_illegal, INPUT_ILLEGAL[Langue]); } } private: //清除输入输出流缓存 void flush() const { _tcin.sync(); _tcout.flush(); } //清除流异常 void clear() const { _tcin.sync(); _tcin.clear(); _tcout.clear(); } //按换行符分割文本 void divideLine(const _tstring& str, int align=-1) const { bool isFinished = false; int begin = 0, end = 0; _tstring subs(VOID_TSTRING); while (!isFinished) { end = str.find('\n', begin); if (end != _tstring::npos) { subs = str.substr(begin, end-begin); putLine(subs, align); begin = end+1; } else { subs = str.substr(begin); putLine(subs, align); isFinished = true; } } } //输出消息盒子里的一行 int putLine(_tstring& str, int align=-1) const { if (align > MAX_LINE_WIDTH - 2) { return 0; }

辛苦您了,谢谢! 辛苦您了,谢谢!
if (!str.empty()) { int maxnum = 0; if (align <= -1) { if (str.length() > MAX_LINE_WIDTH - 2) { str.erase(MAX_LINE_WIDTH - 2); } maxnum = MAX_LINE_WIDTH - 2 - str.length(); align = maxnum / 2; } else { if (str.length() > MAX_LINE_WIDTH - 2 - align) { str.erase(MAX_LINE_WIDTH - 2 - align); } maxnum = MAX_LINE_WIDTH - 2 - str.length(); } _tcout << _T("*"); _tcout.width(align); _tcout.fill(' '); _tcout << VOID_TSTRING<< str; _tcout.width(maxnum - align); _tcout.fill(' '); _tcout << VOID_TSTRING<< _T("*")<< endl; } else { _tcout << _T("*"); _tcout.width(MAX_LINE_WIDTH-2); _tcout.fill(' '); _tcout << VOID_TSTRING<< _T("*")<< endl; } return align; } }; CDebitAccInfo.h 文件 #pragma once #include "IAccountInfo.h" #include "CRenminbi.h" class CDebitAccInfo : public IAccountInfo { public: CDebitAccInfo(const _tstring& pwd, ICash* b)

辛苦您了,谢谢! 辛苦您了,谢谢!
: Password(pwd), Balance(b) { } virtual ~CDebitAccInfo(void) { delete Balance; } //设置密码 virtual void setPassward(const _tstring& pwd) { Password = pwd; } //获取密码 virtual const _tstring& getPassWord() const { return Password; } //获取余额,更改余额 virtual ICash* getBalance() { return Balance; } //获取可用的账户信息 virtual _tstring getAllInfo() const { return (BALANCE_TIP[Langue] + Balance->getCashInfo()); } private: //账户密码 _tstring Password; //账户余额 ICash* Balance; };

CDebitAccount.h 文件 #pragma once #include "CNormalAccount.h" #include "CDebitCard.h" class CDebitAccount :

辛苦您了,谢谢! 辛苦您了,谢谢!
public CNormalAccount { public: CDebitAccount(const _tstring& aid, IAccountInfo* ai, IUserInfo* ui) : CNormalAccount(aid, ai, ui) { } virtual ~CDebitAccount(void) { } //获取账户行为操纵类 virtual ICard* getCard() { return new CDebitCard(this); } //获取账户类型 virtual _tstring getAccountType() const { return DEBIT_ACC_TIP[Langue]; } }; CDebitCard.h 文件 #pragma once #include "ICard.h" #include "INormalAccount.h" #include "CMyException.h" class CDebitCard : public ICard { public: CDebitCard(INormalAccount* nu) : NormalUser(nu) { } virtual ~CDebitCard(void) { } //取款 virtual void withdrawal(ICash* b) {

辛苦您了,谢谢! 辛苦您了,谢谢!
ICash* balance = NormalUser->getBalance(); if (b->compare() > 0 && balance->compare(b) >= 0) { balance->minus(b); } else { throw CMyException(cash_amount_illegal, CASH_AMOUNT_ILLEGAL[Langue]); } } //存款 virtual void deposit(ICash* b) { ICash* balance = NormalUser->getBalance(); if (b->compare() > 0) { balance->plus(b); } else { throw CMyException(cash_amount_illegal, CASH_AMOUNT_ILLEGAL[Langue]); } } //转账 virtual void transfer(IBank* bk, const _tstring& id, ICash* b) { //INormalUser* transacc = NULL; //transacc = dynamic_cast<INormalUser*>(bk->queryAccount(id)); //if (transacc == NULL) { // return; //} //if (b > 0 && b < NormalUser->getBalance()) { // NormalUser->setBalance(NormalUser->getBalance() - b); // transacc->setBalance(transacc->getBalance() + b); //} else { //} } //查询余额 virtual _tstring getBalance() const { return NormalUser->getBalance()->getCashInfo(); } //更改密码 virtual void changePassword(const _tstring& oldpwd, const _tstring& newpwd) { if (NormalUser->isPWDEqual(oldpwd)) { NormalUser->setPassword(newpwd); } else {

辛苦您了,谢谢! 辛苦您了,谢谢!
throw CMyException(password_not_correct, PASSWORD_NOT_CORRECT[Langue]); } } private: INormalAccount* NormalUser; }; CDispenser.h 文件 #pragma once #include "IDispenser.h" #include "IBank.h" #include "CLoginManipulator.h" class CDispenser : public IDispenser { public: CDispenser(IBank* bk) : Bank(bk), Manipulator(new CLoginManipulator(Bank, this)) { } virtual ~CDispenser(void) { delete Manipulator; } //ATM 机开始服务 virtual void serve() { //处理账户登录 Manipulator->handle(); } virtual void poweroff() { //停止操纵类的工作 Manipulator->stop(); } private:

辛苦您了,谢谢! 辛苦您了,谢谢!
//ATM 机服务的银行 IBank* Bank; //ATM 操纵类 IManipulator* Manipulator; }; CDollar.h 文件 #pragma once #include "CCash.h" class CDollar : public CCash { public: CDollar(const double& c) : CCash(c) { } virtual ~CDollar(void) { } //是否是内部货币 virtual bool isInternal(ICash* cash) const { CDollar* dollar = NULL; dollar = dynamic_cast<CDollar*>(cash); if (dollar == NULL) { return false; } else { return true; } } //转换成内部货币 virtual ICash* toInternal(ICash* cash) const { ICash* dollar = NULL; if (isInternal(cash)) { dollar = cash->clone(); } else { dollar = new CDollar(RateToDollar / cash->getRateToDollar() * cash->getCash());

辛苦您了,谢谢! 辛苦您了,谢谢!
} return dollar; } //转换成美元 virtual ICash* toDollar() const { return new CDollar(Cash); } //创建一份拷贝 virtual ICash* clone() const { return new CDollar(Cash); } //获取货币信息 virtual const _tstring& getCurrencyInfo() const { return CurrencyInfo; } //获取当前货币对美元汇率 virtual const float& getRateToDollar() const { return RateToDollar; } //设置当前货币对美元汇率 virtual void setRateToDollar(const float& rate) const { } private: //本种货币信息 static _tstring CurrencyInfo; //本种货币对美元的汇率 static float RateToDollar; }; _tstring CDollar::CurrencyInfo = _T("DOLS"); float CDollar::RateToDollar = 1.0f; CDuplicateAccount.h 文件 #pragma once #include "IDuplicateAccount.h"

辛苦您了,谢谢! 辛苦您了,谢谢!
#include "CDuplicateCard.h" class CDuplicateAccount : public IDuplicateAccount { public: CDuplicateAccount(const _tstring& aid, INormalAccount* nacc) : AccountID(aid), NormalAccount(nacc) { NormalAccount->grab(); } virtual ~CDuplicateAccount(void) { NormalAccount->release(); } //匹配账户 id virtual bool isIDEqual(const _tstring& aid) const { return (AccountID == aid); } //匹配账户密码 virtual bool isPWDEqual(const _tstring& pwd) const { return NormalAccount->isPWDEqual(pwd); } //获取账户 id virtual const _tstring& getAccountID() const { return AccountID; } //设置密码 virtual void setPassword(const _tstring& pwd) { NormalAccount->setPassword(pwd); } //获取余额,更改余额 virtual ICash* getBalance() { return NormalAccount->getBalance(); } //获取可用用户信息 virtual _tstring getUserInfo() const { return NormalAccount->getUserInfo();

辛苦您了,谢谢! 辛苦您了,谢谢!
} //获取可用账户信息 virtual _tstring getAccountInfo() const { _tstring ai(NormalAccount->getAccountInfo()); ai.insert(ai.find('\n'), DUPLICATE_ACC_TIP[Langue]); return ai; } //获取全部可用的信息 virtual _tstring getAllInfo() const { _tstring ai(NormalAccount->getAllInfo()); int bpos = ai.find('\n'); int epos = ai.find('\n', bpos+1); ai.replace(bpos+1, epos-bpos-1, ACCOUNT_ID_TIP[Langue] + AccountID); ai.insert(bpos, DUPLICATE_ACC_TIP[Langue]); return ai; } //获取账户行为操纵类 virtual ICard* getCard() { return new CDuplicateCard(NormalAccount->getCard()); } //获取账户类型 virtual _tstring getAccountType() const { return (NormalAccount->getAccountType()+DUPLICATE_ACC_TIP[Langue]); }

private: //账户 id _tstring AccountID; //主卡指针 INormalAccount* NormalAccount; };

CDuplicateCard.h 文件 #pragma once #include "IDuplicateCard.h"

辛苦您了,谢谢! 辛苦您了,谢谢!
#include "CMyException.h" class CDuplicateCard : public IDuplicateCard { public: CDuplicateCard(ICard* c) : Card(c) { } virtual ~CDuplicateCard(void) { delete Card; } //取款 virtual void withdrawal(ICash* b) { Card->withdrawal(b); } //存款 virtual void deposit(ICash* b) { throw CMyException(dupl_acc_limit, DUPL_ACC_LIMIT[Langue]); } //转账 virtual void transfer(IBank* bk, const _tstring& id, ICash* b) { } //查询余额 virtual _tstring getBalance() const { return Card->getBalance(); } //更改密码 virtual void changePassword(const _tstring& oldpwd, const _tstring& newpwd) { Card->changePassword(oldpwd, newpwd); } private: ICard* Card; };

辛苦您了,谢谢! 辛苦您了,谢谢!
charsetdef.h 文件 #pragma once #include <string> #include <iostream> using namespace std; #include <tchar.h> #if defined(_UNICODE) || defined(UNICODE) typedef wstring _tstring; typedef wstringbuf _tstringbuf; typedef wstringstream _tstringstream; #else typedef string _tstring; typedef stringbuf _tstringbuf; typedef stringstream _tstringstream; #endif

#if defined(_UNICODE) || defined(UNICODE) typedef wios _tios; typedef wistream _tistream; typedef wostream _tostream; typedef wiostream _tiostream; #define _tcin #define _tcout #define _tcerr #define _tclog #else typedef ios typedef istream typedef ostream typedef iostream #define _tcin #define _tcout #define _tcerr #define _tclog #endif wcin wcout wcerr wclog _tios; _tistream; _tostream; _tiostream; cin cout cerr clog

辛苦您了,谢谢! 辛苦您了,谢谢!
CLoginManipulator.h 文件 #pragma once #include "CManipulator.h" #include "CNormalManipulator.h" #include "CAdminManipulator.h" #include "INormalAccount.h" #include "IAdminAccount.h" class CLoginManipulator : public CManipulator { public: CLoginManipulator(IBank* bk, IDispenser* disp, IManipulator* m=NULL) : CManipulator(disp, m), Bank(bk), AdminManipulator(NULL) , NormalManipulator(NULL) { } virtual ~CLoginManipulator(void) { if (AdminManipulator != NULL) { delete AdminManipulator; AdminManipulator = NULL; } if (NormalManipulator != NULL) { delete NormalManipulator; NormalManipulator = NULL; } } //设置服务请求者 virtual void setRequester(IAccount* acc) { } //处理请求 virtual void handle() { //重置处理状态 isFinished = false; CUI->screenColor("07"); IAccount* acc = NULL; while (!isFinished) {

辛苦您了,谢谢! 辛苦您了,谢谢!
try { //打印欢迎信息 displayTitle(); //用户登陆 acc = login(); //处理用户请求 dealWithUser(acc); } catch(CMyException err) { CUI->messageBox(VOID_TSTRING, err.what()); CUI->screenHold(); } CUI->screenClean(); } } protected: //打印欢迎信息 void displayTitle() { CUI->messageBox(WELCOME_INFO[Langue],LOGIN_TIP[Langue]); } //用户登陆 IAccount* login() { _tstring aid(VOID_TSTRING); _tstring pwd(VOID_TSTRING); aid = CUI->lineBox(ACCOUNT_ID_TIP[Langue]); TypeCheck->isAccountID(aid); pwd = CUI->passwordBox(PASSWORD_TIP[Langue]); TypeCheck->isPassword(pwd); IAccount* acc = Bank->queryAccount(aid); if (!acc->isPWDEqual(pwd)) { throw CMyException(access_deny, ACCESS_DENY[Langue]); } return acc; } //处理用户请求

辛苦您了,谢谢! 辛苦您了,谢谢!
void dealWithUser(IAccount* acc) { //登陆成功,提示信息 CUI->messageBox(VOID_TSTRING, LOGIN_SUCC_INFO[Langue]); CUI->screenHold(); INormalAccount* nuser = NULL; IAdminAccount* admin = NULL; if ((nuser = dynamic_cast<INormalAccount*>(acc)) != NULL) { //处理普通用户登陆 if (NormalManipulator == NULL) { NormalManipulator = new CNormalManipulator(nuser, Dispenser); } setSuccessor(NormalManipulator); getSuccessor()->setRequester(nuser); } else if ((admin = dynamic_cast<IAdminAccount*>(acc)) != NULL) { //处理管理员登陆 if (AdminManipulator == NULL) { AdminManipulator = new CAdminManipulator(admin, Dispenser); } setSuccessor(AdminManipulator); getSuccessor()->setRequester(admin); } else { //未知用户,抛出异常 throw CMyException(unknow_error, UNKNOW_ERROR[Langue]); } //交给后继结点处理 getSuccessor()->handle(); } private: //进行操作的银行 IBank* Bank; //管理员操纵类 IManipulator* AdminManipulator; //普通账户操作类 IManipulator* NormalManipulator; };

辛苦您了,谢谢! 辛苦您了,谢谢!
CManipulator.h 文件 #pragma once #include "IManipulator.h" #include "IDispenser.h" #include "CCUI.h" #include "CTypeCheck.h" #include "CMyException.h" class CManipulator : public IManipulator { public: CManipulator(IDispenser* disp, IManipulator* m=NULL) : Dispenser(disp), Manipulator(m), isFinished(false) , CUI(new CCUI()), TypeCheck(new CTypeCheck()) { } virtual ~CManipulator(void) { delete CUI; delete TypeCheck; } //获取后继处理节点 virtual IManipulator* getSuccessor() const { return Manipulator; } //设置后继处理节点 virtual void setSuccessor(IManipulator* m) { Manipulator = m; } //停止处理 virtual void stop() { if (getSuccessor() != NULL) { getSuccessor()->stop(); } isFinished = true; } protected:

辛苦您了,谢谢! 辛苦您了,谢谢!
//当前节点是否处理完成 bool isFinished; //用户界面类 ICUI* CUI; //类型检查类 ITypeCheck* TypeCheck; //取款机类 IDispenser* Dispenser; private: //后继处理节点 IManipulator* Manipulator; }; CMyException.h 文件 #pragma once #include "EErrorCode.h" class CMyException { public: CMyException(const int code, const _tstring& msg) : ErrorCode(code), ErrorMessage(msg) { } virtual ~CMyException(void) { } virtual int getErrorCode() const throw() { return ErrorCode; } virtual const _tstring& what() const throw() { return ErrorMessage; } private:

辛苦您了,谢谢! 辛苦您了,谢谢!
//错误代码 int ErrorCode; //错误消息 _tstring ErrorMessage; }; CNormalAccount.h 文件 #pragma once #include <iostream> #include "INormalAccount.h" #include "CMyException.h" using namespace std; class CNormalAccount : public INormalAccount { public: CNormalAccount(const _tstring& aid, IAccountInfo* ai, IUserInfo* ui) : AccountID(aid), AccountInfo(ai), UserInfo(ui) { AccountInfo->grab(); UserInfo->grab(); } virtual ~CNormalAccount(void) { AccountInfo->release(); UserInfo->release(); } //增加引用计数 virtual void grab() { ++Count; if (Count > 5) { --Count; throw CMyException(dupl_acc_amount_limit, DUPL_ACC_AMOUNT_LIMIT[Langue]); } } //减少引用计数

辛苦您了,谢谢! 辛苦您了,谢谢!
virtual void release() { --Count; } //匹配账户 id virtual bool isIDEqual(const _tstring& aid) const { return (AccountID == aid); } //匹配账户密码 virtual bool isPWDEqual(const _tstring& pwd) const { return (AccountInfo->getPassWord() == pwd); } //获取账户 id virtual const _tstring& getAccountID() const { return AccountID; } //设置密码 virtual void setPassword(const _tstring& pwd) { AccountInfo->setPassward(pwd); } //获取余额,更改余额 virtual ICash* getBalance() { return AccountInfo->getBalance(); } //获取可用用户信息 virtual _tstring getUserInfo() const { return UserInfo->getAllInfo(); } //获取可用账户信息 virtual _tstring getAccountInfo() const { return (ACC_TYPE_TIP[Langue] + getAccountType() + NEXT_LINE + AccountInfo->getAllInfo()); } //获取全部可用的信息 virtual _tstring getAllInfo() const { return (ACC_TYPE_TIP[Langue] + getAccountType() + NEXT_LINE + ACCOUNT_ID_TIP[Langue] + AccountID + NEXT_LINE +

辛苦您了,谢谢! 辛苦您了,谢谢!
getUserInfo() + NEXT_LINE + AccountInfo->getAllInfo()); } protected: //账户 id _tstring AccountID; //用户信息 IUserInfo* UserInfo; //账户信息 IAccountInfo* AccountInfo; }; CNormalManipulator.h 文件 #pragma once #include "INormalAccount.h" #include "CManipulator.h" #include "CDollar.h" #include "CRenminbi.h" class CNormalManipulator : public CManipulator { public: CNormalManipulator(INormalAccount* nuser, IDispenser* disp, IManipulator* m=NULL) : CManipulator(disp, m), NUser(nuser), Card(nuser->getCard()) { } virtual ~CNormalManipulator(void) { delete Card; } //设置服务请求者 virtual void setRequester(IAccount* acc) { INormalAccount* nuser = NULL; nuser = dynamic_cast<INormalAccount*>(acc); if (nuser == NULL) {

辛苦您了,谢谢! 辛苦您了,谢谢!
throw CMyException(unknow_error, UNKNOW_ERROR[Langue]); } delete Card; NUser = nuser; Card = NUser->getCard(); } //处理请求 virtual void handle() { //重置处理状态 isFinished = false; CUI->screenClean(); CUI->screenColor("0A"); int ch = 0; while (!isFinished) { try { //显示菜单 diplayMenu(); //用户选择操作 ch = CUI->selectionBox(CHOICE_TIP[Langue], 3); //处理用户请求 processEvent(ch); } catch(CMyException err) { CUI->messageBox(VOID_TSTRING, err.what()); CUI->screenHold(); } } CUI->screenColor("07"); } protected: //显示菜单 void diplayMenu() { CUI->messageBox(ACC_TYPE_TIP[Langue] + NUser->getAccountType(), NRL_USER_MENU[Langue], -2); } //处理用户选择 void processEvent(int ch) {

辛苦您了,谢谢! 辛苦您了,谢谢!
switch (ch) { case 1: withdrawal(); break; case 2: deposit(); break; case 3: queryBalance(); break; //case 4: // transferAccounts(); // break; case 0: stop(); break; default: throw CMyException(choice_illegal, CHOICE_ILLEGAL[Langue]); } } //取款 void withdrawal() { _tstring b(VOID_TSTRING); ICash* cash = NULL; CUI->messageBox(VOID_TSTRING, WITHDRAWAL_TIP[Langue]); if (CUI->acknowledgeBox(CURRENCY_SEL_TIP[Langue], 'r', 'd')) { b = CUI->lineBox(CASH_CNY_TIP[Langue]); TypeCheck->isHundred(b); cash = new CRenminbi(_tstof(b.c_str())); } else { b = CUI->lineBox(CASH_DOLS_TIP[Langue]); TypeCheck->isHundred(b); cash = new CDollar(_tstof(b.c_str())); } Card->withdrawal(cash); CUI->messageBox(WITHDRAWAL_SUCC_TIP[Langue], BALANCE_TIP[Langue] + Card->getBalance()); CUI->screenHold(); }

辛苦您了,谢谢! 辛苦您了,谢谢!
//存款 void deposit() { _tstring b(VOID_TSTRING); ICash* cash = NULL; CUI->messageBox(VOID_TSTRING, DEPOSIT_TIP[Langue]); if (CUI->acknowledgeBox(CURRENCY_SEL_TIP[Langue], 'r', 'd')) { b = CUI->lineBox(CASH_CNY_TIP[Langue]); TypeCheck->isHundred(b); cash = new CRenminbi(_tstof(b.c_str())); } else { b = CUI->lineBox(CASH_DOLS_TIP[Langue]); TypeCheck->isHundred(b); cash = new CDollar(_tstof(b.c_str())); } Card->deposit(cash); CUI->messageBox(DEPOSIT_SUCC_TIP[Langue], BALANCE_TIP[Langue] + Card->getBalance()); CUI->screenHold(); } //查询余额 void queryBalance() { CUI->messageBox(QUERY_BALANCE_TIP[Langue], BALANCE_TIP[Langue] + Card->getBalance()); CUI->screenHold(); } //转账 void transferAccounts() { } private: //进行操作的用户 INormalAccount* NUser; //用户使用的卡 ICard* Card; }; CRenminbi.h 文件 #pragma once

辛苦您了,谢谢! 辛苦您了,谢谢!
#include "CDollar.h" class CRenminbi : public CCash { public: CRenminbi(const double& c) : CCash(c) { } virtual ~CRenminbi(void) { } //是否是内部货币 virtual bool isInternal(ICash* cash) const { CRenminbi* rmb = NULL; rmb = dynamic_cast<CRenminbi*>(cash); if (rmb == NULL) { return false; } else { return true; } } //转换成内部货币 virtual ICash* toInternal(ICash* cash) const { ICash* rmb = NULL; if (isInternal(cash)) { rmb = cash->clone(); } else { rmb = new CRenminbi(RateToDollar / cash->getRateToDollar() * cash->getCash()); } return rmb; } //转换成美元 virtual ICash* toDollar() const { return new CDollar(Cash / RateToDollar); } //创建一份拷贝 virtual ICash* clone() const {

辛苦您了,谢谢! 辛苦您了,谢谢!
return new CRenminbi(Cash); } //获取货币信息 virtual const _tstring& getCurrencyInfo() const { return CurrencyInfo; } //获取当前货币对美元汇率 virtual const float& getRateToDollar() const { return RateToDollar; } //设置当前货币对美元汇率 virtual void setRateToDollar(const float& rate) const { RateToDollar = rate; } private: //本种货币信息 static _tstring CurrencyInfo; //本种货币对美元的汇率 static float RateToDollar; }; _tstring CRenminbi::CurrencyInfo = _T("CNY"); float CRenminbi::RateToDollar = 7.5f; 注释:这只是其中一部分程序,由于太多了,复制比较麻烦,忘贵公司谅解!辛苦您了,谢 谢!

<HTML> <TITLE>BLAST Search </TITLE> <head> <link href="../css/index.css" rel="stylesheet" type="text/css" /> </head> <BODY style="BGCOLOR:#000000;LINK:#0000FF; VLINK:#660099; ALINK:#660099;line-height:240%;font-size:small; "> <div id="layout"><div id="head" style="white-space:nowrap;"><div style="text-shadow:2px 3px 2px #CCC;font-size:small;"><span style="font-size:52px;line-height:110%">PGED</span>Data Repository For Porcine Gene

辛苦您了,谢谢! 辛苦您了,谢谢!
Expression Data</div> <p><ul id="nav" > <li id="li_home"><font size="4"><a href="../index.php" >Home</a></font></li> <li><font size="4"><a href="../search.php">Search</a></font></li> <li><font size="4"><a href="blast.php">Blast</a></font></li> <li><font size="4"><a href="../Gene_browse.php">Gene Browse</a></font></li> <li><font size="4"><a href="../EST_browse.php">EST Browse</a></font></li> </ul></p> </div> <map name=img_map> <!--<area shape=rect coords=2,1,48,21 href="http://www.ncbi.nlm.nih.gov">--> <!--<area shape=rect coords=385,1,435,21 href="index.html"> <area shape=rect coords=436,1,486,21 href="http://www.ncbi.nlm.nih.gov/Entrez/">--> <area shape=rect coords=487,1,508,21 href="docs/blast_help.html"> </map>

<FORM ACTION="blast.cgi" METHOD = POST NAME="MainBlastForm" ENCTYPE= "multipart/form-data" > <P style="padding-left:50px;padding-right:50px;" > Enter sequence below in <a href="docs/fasta.html">FASTA</a> </P> <p style="padding-left:50px;padding-right:50px;"><textarea name="SEQUENCE" rows=6 cols=60> if(isset isset($_POST['fasta' 'fasta'])) echo $_POST['fasta' ?> 'fasta'];?> <?php if isset 'fasta' 'fasta' </textarea> </p> <b>Choose program to use to search:</b> <p style="padding-left:50px;padding-right:50px;"><input type="radio" name="PROGRAM" value="blastp" /><b>blastp</b>:compares an amino acid query sequence against a protein sequence database </p> <p style="padding-left:50px;padding-right:50px;"><input type="radio" name="PROGRAM" value="blastn" /><b>blastn</b>:compares a nucleotide query sequence against a nucleotide sequence database </p> <p style="padding-left:50px;padding-right:50px;"><input type="radio" name="PROGRAM" value="blastx" /><b>blastx</b>:compares a nucleotide query sequence translated in all reading frames against a protein sequence database </p> <p style="padding-left:50px;padding-right:50px;"><input type="radio" name="PROGRAM" value="tblastn" /><b>tblastn</b>:compares a protein query sequence against a nucleotide sequence database dynamically translated in all reading frames </p> <p style="padding-left:50px;padding-right:50px;"><input type="radio" name="PROGRAM" value="tblastx" /><b>tblastx</b>:compares the six-frame translations of a nucleotide query sequence against the six-frame translations of a nucleotide sequence database. Please note that tblastx program cannot be used with the nr database on the BLAST Web format

辛苦您了,谢谢! 辛苦您了,谢谢!
page. </p> <!-- <a href="docs/blast_databases.html">Database</a>--> <b>Choose database to search:</b> <p style="padding-left:50px;padding-right:50px;"><input type="radio" name="DATALIB" value="est_mouse">est_mouse</input></p> <p style="padding-left:50px;padding-right:50px;"><input type="radio" name="DATALIB" value="est_human">est_human</input></p> <!-<select name = "DATALIB"> <option VALUE = "est_mouse"> est_mouse <option VALUE = "est_human"> est_human </select> --> <!-Enter here your input data as <select name = "INPUT_TYPE"> <option> Sequence in FASTA format <option> Accession or GI </select> --> <!--<BR> Or load it from disk <INPUT TYPE="file" NAME="SEQFILE"> <P> Set subsequence: From &nbsp;&nbsp<input TYPE="text" NAME="QUERY_FROM" VALUE="" SIZE="10"> &nbsp;&nbsp&nbsp;&nbsp To <input TYPE="text" NAME="QUERY_TO" VALUE="" SIZE="10"> <P> <INPUT TYPE="button" VALUE="Clear sequence" onClick="MainBlastForm.SEQUENCE.value='';MainBlastForm.QUERY_FROM.value='';MainBlas tForm.QUERY_TO.value='';MainBlastForm.SEQUENCE.focus();"> <INPUT TYPE="submit" VALUE="Search"> <HR>--> <p style="padding-left:50px;padding-right:50px;"> The query sequence is <a href="docs/filtered.html">filtered</a> for low complexity regions by default. <BR> <a href="docs/newoptions.html#filter">Filter</a> <INPUT TYPE="checkbox" VALUE="L" NAME="FILTER" CHECKED> Low complexity <INPUT TYPE="checkbox" VALUE="m" NAME="FILTER"> Mask for lookup table only <P style="padding-left:50px;padding-right:50px;">

辛苦您了,谢谢! 辛苦您了,谢谢!
<a href="docs/newoptions.html#expect">Expect</a> <select name = "EXPECT"> <option> 0.0001 <option> 0.01 <option> 1 <option selected> 10 <option> 100 <option> 1000 </select> &nbsp;&nbsp; <a href="docs/matrix_info.html">Matrix</a> <select name = "MAT_PARAM"> <option value = "PAM30 <option value = "PAM70 9 10 1"> PAM30 </option> 1"> PAM70 </option> 1"> BLOSUM80 </option> 11 1"> BLOSUM62 </option> 2"> BLOSUM45 </option> CHECKED>

<option value = "BLOSUM80 10 <option value = "BLOSUM45 14 </select>

<option selected value = "BLOSUM62

<INPUT TYPE="checkbox" NAME="OVERVIEW"

<a href="docs/newoptions.html#graphical-overview">Graphical Overview</a> &nbsp;&nbsp; <a href="docs/options.html#alignmentviews">Alignment view</a> <select name = "ALIGNMENT_VIEW"> <option value=0> Pairwise <option value=1> master-slave with identities <option value=2> master-slave without identities <option value=3> flat master-slave with identities <option value=4> flat master-slave without identities <option value=7> BLAST XML <option value=9> Hit Table </select> <BR> <a href="docs/newoptions.html#descriptions">Descriptions</a> <select name = "DESCRIPTIONS"> <option> 0 <option> 10 <option> 50 <option selected> 100 <option> 250 <option> 500 </select> &nbsp;&nbsp;

辛苦您了,谢谢! 辛苦您了,谢谢!
<a href="docs/newoptions.html#alignments">Alignments</a> <select name = "ALIGNMENTS"> <option> 0 <option> 10 <option selected> 50 <option> 100 <option> 250 <option> 500 </select> <a href="docs/color_schema.html">Color schema</a> <select name = "COLOR_SCHEMA"> <option selected value = 0> No color schema <option value = 1> Color schema 1 <option value = 2> Color schema 2 <option value = 3> Color schema 3 <option value = 4> Color schema 4 <option value = 5> Color schema 5 <option value = 6> Color schema 6 </select> <p style="text-align:center"> <INPUT TYPE="button" VALUE="Clear sequence" onClick="MainBlastForm.SEQUENCE.value='';MainBlastForm.SEQFILE.value='';MainBlastFo rm.SEQUENCE.focus();"> <INPUT TYPE="submit" VALUE="Blast"> </FORM> <div id="foot" style="padding-left:0px;padding-right:0px;" > <div id="innerfoot" > <img id="hzau" src="../img/hzau.png" alt="hzau" title="HUAZHONG AGRICULTURAL UNIVERCITY" /><img id="nsfc" src="../img/nsfc.png" alt="nsfc" title="NATIONAL SCIENCE FOND COMMITTEE" /> </div> <div </div> </div> </BODY> </HTML> style="text-align:center;background:#dedeee;"> <p>&reg;HuaZhong (Central China) Agricultural University</p></div>

这是基于 web 的动物细胞基因信息搜索的主页面


赞助商链接
相关文章:
网页设计部分代码
网页设计部分代码_互联网_IT/计算机_专业资料。网页设计部分代码 一 网页设计的 HTML 语言的简单介绍 然后在该站点下建立网页文件等。 <!DOCTYPE html PUBLIC "-...
部分代码
6页 免费 接收部分代码 3页 5财富值 发送部分代码 暂无评价 4页 5财富值 部分实验代码 19页 2财富值 部分设计代码 1页 免费喜欢...
部分代码
6页 免费 接收部分代码 3页 5财富值 发送部分代码 暂无评价 4页 5财富值 部分实验代码 19页 2财富值 部分设计代码 1页 免费喜欢...
部分代码
发送部分代码 暂无评价 4页 5财富值 部分实验代码 19页 2财富值 部分设计代码 1页 免费如要投诉违规内容,请到百度文库投诉中心;如要提出功能问题或意见建议,请点...
visual basic 部分代码
visual basic 部分代码_工学_高等教育_教育专区。visual basic 代码 1 Private Sub Command1_Click() Text1.Text = "" End Sub Private Sub Text1_Change()...
网页设计各部分代码的作用
网页设计各部分代码的作用_互联网_IT/计算机_专业资料。网页设计各部分代码的作用1. HTML 文档开始与结束标记 标记格式: <HTML>……</HTML> <HTML>标记用于标记...
部分实验代码
实验代码 5页 1财富值 C# 实验代码 25页 5财富值 实验代码 1页 20财富值 实验代码 5页 2财富值 VB部分实验题代码 3页 免费 ...
原始话单中的部分代码含义
原始话单中的部分代码含义 GSMPLMNCallDataRecord mSTerminating chargeableDuration dateForStartofCharge exchangeIdentity lastPartialOutput partialOutputRecNum record...
播放器部分代码
播放器部分代码_理学_高等教育_教育专区。C#版本的音乐播放器代码using using using using using using using using using System; System.IO; System.Collections.Ge...
部分代码特效
部分代码特效_互联网_IT/计算机_专业资料 暂无评价|0人阅读|0次下载|举报文档 部分代码特效_互联网_IT/计算机_专业资料。 投影及旋转效果 <!DOCTYPE html> <...
更多相关标签: