static void createAccount([Domain("new")] Account account, int id, ACCT_TYPE acctType, int balance)
 {
     account.id       = id;
     account.acctType = acctType;
     account.balance  = balance;
     allAccounts      = allAccounts.Add(account);
 }
Exemple #2
0
        internal bool transfer(ACCT_TYPE fromType, ACCT_TYPE toType, int cents)
        {
            Account fromAccount = null;

            if (!accounts.ContainsKey(fromType))
            {
                Session.addMessage(MSG.INVALID_FROM_ACCT);
            }
            else
            {
                fromAccount = accounts[fromType];
                if (fromAccount.balance < cents)
                {
                    Session.addMessage(MSG.INVALID_ACCT_BALANCE);
                }
            }
            if (!accounts.ContainsKey(toType))
            {
                Session.addMessage(MSG.INVALID_TO_ACCT);
            }
            if (fromType == toType)
            {
                Session.addMessage(MSG.SAME_ACCOUNT);
            }
            if (Session.hasMessages())
            {
                return(false);
            }
            Account toAccount = accounts[toType];

            fromAccount.balance = fromAccount.balance - cents;
            toAccount.balance   = toAccount.balance + cents;
            return(true);
        }
 static void resetTransaction()
 {
     transType   = TRANS_TYPE.NONE;
     fromAccount = ACCT_TYPE.EMPTY;
     toAccount   = ACCT_TYPE.EMPTY;
     transAmount = NAN;
     pinRetries  = 0;
 }
 static MSG custSelectAcct([Domain("AcctTypes")] ACCT_TYPE accountType)
 {
     if (fromAccount == ACCT_TYPE.EMPTY)
     {
         fromAccount = accountType;
         return(transType == TRANS_TYPE.WITHDRAWAL ? MSG.ENTER_AMOUNT : MSG.SELECT_TO_ACCT);
     }
     else
     {
         toAccount = accountType; return(MSG.ENTER_AMOUNT);
     }
 }
Exemple #5
0
        internal bool withdrawal(ACCT_TYPE fromType, int dollars)
        {
            if (todaysWithdrawal + dollars > maxWithdrawal)
            {
                Session.addMessage(MSG.MAX_DAILY_WITHDRAWAL);
            }
            if (!accounts.ContainsKey(fromType))
            {
                Session.addMessage(MSG.INVALID_FROM_ACCT); return(false);
            }
            Account fromAccount = accounts[fromType];

            if (fromAccount.balance < dollars * 100)
            {
                Session.addMessage(MSG.INVALID_ACCT_BALANCE);
            }
            if (Session.hasMessages())
            {
                return(false);
            }
            fromAccount.balance = fromAccount.balance - dollars * 100;
            todaysWithdrawal    = todaysWithdrawal + dollars;
            return(true);
        }
 static void resetTransaction()
 {
     transType = TRANS_TYPE.NONE;
     fromAccount = ACCT_TYPE.EMPTY;
     toAccount = ACCT_TYPE.EMPTY;
     transAmount = NAN;
     pinRetries = 0;
 }
 static MSG custSelectAcct([Domain("AcctTypes")] ACCT_TYPE accountType)
 {
     if (fromAccount == ACCT_TYPE.EMPTY)
     {
         fromAccount = accountType;
         return transType == TRANS_TYPE.WITHDRAWAL ? MSG.ENTER_AMOUNT : MSG.SELECT_TO_ACCT;
     }
     else { toAccount = accountType; return MSG.ENTER_AMOUNT; }
 }
 /// <remarks/>
 public override void Initialize()
 {
     id       = 0;
     acctType = ACCT_TYPE.EMPTY;
     balance  = 0;
 }