当前位置: 首页>>代码示例>>C++>>正文


C++ Account::_set_trans_list方法代码示例

本文整理汇总了C++中Account::_set_trans_list方法的典型用法代码示例。如果您正苦于以下问题:C++ Account::_set_trans_list方法的具体用法?C++ Account::_set_trans_list怎么用?C++ Account::_set_trans_list使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Account的用法示例。


在下文中一共展示了Account::_set_trans_list方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
}
开发者ID:OS2World,项目名称:DEV-SAMPLES-SOM-IBM,代码行数:90,代码来源:BANK.CPP


注:本文中的Account::_set_trans_list方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。