public bool SetInterestRate(decimal pSetInterest, AccountSelect pSelectSetIrate) { switch (pSelectSetIrate) { ///in the case where pSelectSetIrate == AccountSelect.Account case AccountSelect.Account: ///if Account.SetInterest given pSetInterest ///returns true then this method also returns true ///not to mention we have already set the interest at this point if (Account.SetInterest(pSetInterest)) { return(true); } else { ///otherwise we return false return(false); } case AccountSelect.StudentAccount: if (StudentAccount.SetInterest(pSetInterest)) { return(true); } else { return(false); } ///if pSelectSetIrate != to Account or StudentAccount then it cannot accept Interest alterations so return false default: return(false); } }
public int GetOverdraftLimit(AccountSelect pSelectGetOLimit) { switch (pSelectGetOLimit) { case AccountSelect.Account: return(Account.GetOverdraftLimit()); case AccountSelect.StudentAccount: return(StudentAccount.GetOverdraftLimit()); default: return(0); } }
public decimal GetInterestRate(AccountSelect pSelectAccount) { switch (pSelectAccount) { case AccountSelect.Account: return(Account.GetInterest()); case AccountSelect.StudentAccount: return(StudentAccount.GetInterest()); default: return(0); } }
public IAccount AddAccount(AccountSelect pSelectAdd, string pName, string pAddress, decimal pBalance, decimal pOverdraft) { ///Look through the array of references looking for ///an appropriate place to store a reference to the new account for (uint i = 0; i < m_Accounts.Length; ++i) { if (m_Accounts[i] == null) //if there is an empty space to store an Account reference { ///this switch statement works on the enum type that was passed into this method ///it finds out what type of account you wish to create and makes an instance of it ///which can be pointed to/accessed by the IAccount array l_index, m_Accounts[i] switch (pSelectAdd) { ///in the case the variable pSelectAdd ///holds the enum type AccountSelect.Account case AccountSelect.Account: ///make a new Account class instance by calling its constructor ///with the bracketed parameters and reference to it ///from the IAccount array l_index m_Accounts[i] m_Accounts[i] = new Account(dt.Year.ToString() + "A" + sm_NextAccountNumber.ToString("X"), pName, pAddress, pBalance, pOverdraft); break; case AccountSelect.BabyAccount: ///ditto but making a new BabyAccount class instance ///the constructor has no overdraft! m_Accounts[i] = new BabyAccount(dt.Year.ToString() + "A" + sm_NextAccountNumber.ToString("X"), pName, pAddress, pBalance); break; case AccountSelect.StudentAccount: ///currentyear, "A", HexAccountNo, name, address, balance, overdraft m_Accounts[i] = new StudentAccount(dt.Year.ToString() + "A" + sm_NextAccountNumber.ToString("X"), pName, pAddress, pBalance, pOverdraft); break; default: continue; } // increment the next account number sm_NextAccountNumber++; // and return the reference to the new account return(m_Accounts[i]); } } ///if you can't find a place to store the new account ///(i.e. the bank is full) then return null. return(null); }
private void OnLoaded(object sender, RoutedEventArgs e) { installing = true; DisplayInformation.GetForCurrentView().OrientationChanged += MultiSelect_OrientationChanged; FamilyMemberSelect.SelectAll(); AccountSelect.SelectedItems.Add(AccountSelect.Items[0]); AccountSelect.SelectedItems.Add(AccountSelect.Items[2]); IncomeDetailsSelect.SelectedItems.Add(IncomeDetailsSelect.Items[0]); IncomeDetailsSelect.SelectedItems.Add(IncomeDetailsSelect.Items[1]); ExpenseDetailsSelect.SelectedItems.Add(ExpenseDetailsSelect.Items[0]); ExpenseDetailsSelect.SelectedItems.Add(ExpenseDetailsSelect.Items[1]); ExpenseDetailsSelect.SelectedItems.Add(ExpenseDetailsSelect.Items[5]); FamilyMemberSelect.AddHandler(PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true); AccountSelect.AddHandler(PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true); IncomeDetailsSelect.AddHandler(PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true); ExpenseDetailsSelect.AddHandler(PointerPressedEvent, new PointerEventHandler(OnPointerPressed), true); installing = false; }
public byte SetOverdraftLimit(int pSetLimit, AccountSelect pSelectSetOLimit) { ///set to the lowest possible overdraft limit to begin with decimal l_HighestOverdraft = 0; ///obviously pSetLimit (the amount we want the overdraft limit to be) ///must be a positive value if (pSetLimit >= 0) { ///what type of account do we want the overdraft limit to be modified on? switch (pSelectSetOLimit) { ///case where the user selected 'Account' case AccountSelect.Account: ///search every reference in IAccount array m_Accounts foreach (IAccount a in m_Accounts) { ///if reference pointing somewhere ie.(not null) ///AND the reference is pointing to an 'Account' if ((a != null) && (a.GetType().Name == "Account")) { ///if the overdraft of currently accessed account is ///greater than previous value in l_HighestOvedraft if (a.GetOverdraft() > l_HighestOverdraft) { ///then the new total becomes this overdraft l_HighestOverdraft = a.GetOverdraft(); } } } ///if the number we want to modify the overdraft limit to ///is greater than the highest existing overdraft ///held by any customer of this type of 'Account' if (pSetLimit >= l_HighestOverdraft) { ///then set the overdraft limit to what we asked Account.SetOverdraftLimit(pSetLimit); return(0); ///return 0 == return true } else { return(2); ///error: overdraft limit we wanted was less than one of the customers existing overdrafts of this account type } ///case where the user selected 'StudentAccount' ///ditto as above case AccountSelect.StudentAccount: foreach (IAccount a in m_Accounts) { if ((a != null) && (a.GetType().Name == "StudentAccount")) { if (a.GetOverdraft() > l_HighestOverdraft) { l_HighestOverdraft = a.GetOverdraft(); } } } if (pSetLimit >= l_HighestOverdraft) { StudentAccount.SetOverdraftLimit(pSetLimit); return(0); ///return 0 == return true } else { return(2); ///error: overdraft limit we wanted was less than one of the customers existing overdrafts of this account type } default: return(3); ///the account type you want to alter overdraft limit to does not support changes to the overdraft limit } } else { return(1); ///error: user tried to set overdraft limit to a negative } }