本文整理汇总了C++中Account::_get_user_name方法的典型用法代码示例。如果您正苦于以下问题:C++ Account::_get_user_name方法的具体用法?C++ Account::_get_user_name怎么用?C++ Account::_get_user_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Account
的用法示例。
在下文中一共展示了Account::_get_user_name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Close
SOM_Scope long SOMLINK Close(Bank *somSelf, Environment *ev,
string name, long acct_type, long pin)
{
Account *temp;
somf_TSetIterator *itr;
somf_TPrimitiveLinkedList *l;
int freed = 0;
somf_TSet *setptr;
string user_name;
BankData *somThis = BankGetData(somSelf);
BankMethodDebug("Bank","Close");
itr = new somf_TSetIterator;
switch (acct_type)
{
case Account_CHECKING:
setptr = somSelf->_get_check_acct_set(ev);
itr->somfTSetIteratorInit(ev, setptr);
break;
case Account_SAVINGS:
setptr = somSelf->_get_save_acct_set(ev);
itr->somfTSetIteratorInit(ev, setptr);
break;
case Account_MF:
setptr = somSelf->_get_mf_acct_set(ev);
itr->somfTSetIteratorInit(ev, setptr);
break;
default:
somPrintf (" bad account type\n");
return 9;
}
temp = (Account *) itr->somfFirst(ev);
while (!((SOMDObject *)temp)->is_nil((SOMDObject *)temp,ev))
{
user_name = temp->_get_user_name(ev);
if (strcmp(name, user_name) == 0) {
if (temp->_get_pin(ev) == pin) {
if (setptr->somfRemove(ev, temp) != SOMF_NIL)
return Account_OK;
else
return 9;
}
else
return Account_BAD_PIN;
}
else
temp = (Account *)itr->somfNext(ev);
}
return Account_NO_ACCT;
}
示例2: if
SOM_Scope long SOMLINK Open(Bank *somSelf, Environment *ev,
string name, long acct_type, long pin,
long amount)
{
BankData *somThis = BankGetData(somSelf);
BankMethodDebug("Bank","Open");
Account *temp;
somf_TSetIterator *itr;
trans_info *Tr;
somf_TSet *set;
somf_TPrimitiveLinkedList *llist;
char *user_name;
/* first check if the account already exists */
/* we create an iterator and walk through the account list */
itr = new somf_TSetIterator;
switch (acct_type)
{
case Account_CHECKING:
itr->somfTSetIteratorInit(ev, somSelf->_get_check_acct_set(ev));
break;
case Account_SAVINGS:
itr->somfTSetIteratorInit(ev, somSelf->_get_save_acct_set(ev));
break;
case Account_MF:
itr->somfTSetIteratorInit(ev, somSelf->_get_mf_acct_set(ev));
break;
default:
somPrintf (" bad account type\n");
return 9;
}
temp = (Account *)itr->somfFirst(ev);
while (temp != SOMF_NIL )
{
user_name = temp->_get_user_name(ev);
if (strcmp(name, user_name) == 0) { /* acct already exists ? */
somPrintf("<%s> exists\n", name);
return Account_ACCT_EXISTS;
}
else
temp = (Account *)itr->somfNext(ev);
}
/* if we are here then we need to add the account
* initialize all values (hardwire interest and min_balance)
* allocate space for the new account
*/
user_name = (char *) malloc (strlen(name) + 1);
strcpy (user_name, name);
temp = new Account;
temp->_set_user_name (ev, user_name);
temp->_set_min_balance (ev, 0);
temp->_set_act_balance (ev, amount);
temp->_set_interest (ev, 5);
temp->_set_pin (ev, pin);
llist = new somf_TPrimitiveLinkedList;
/* initialize the transaction list also */
Tr = new trans_info;
Tr->_set_amount (ev, amount);
Tr->_set_transaction (ev, Account_OPEN);
Tr->_set_date (ev, time(0));
Tr->_set_curr_bal (ev, amount);
llist->somfAddFirst(ev, Tr);
/* now set up all the information to point correctly */
temp->_set_trans_list (ev, llist);
/* now add the account to the appropriate set */
if (acct_type == Account_CHECKING) {
set = somSelf->_get_check_acct_set(ev);
set->somfAdd(ev, temp);
}
else if (acct_type == Account_SAVINGS) {
set = somSelf->_get_save_acct_set(ev);
set->somfAdd(ev, temp);
}
else if (acct_type == Account_MF) {
set = somSelf->_get_mf_acct_set(ev);
set->somfAdd(ev, temp);
}
itr->somFree();
return Account_OK;
}