public static bool AddCreditAccount(string AccNumber, Customer cust) { List <Transaction> tempList = new List <Transaction>(); CreditAccount NewAccount = new CreditAccount(0, 5000, 0.5, 7, AccNumber, "credit", tempList, true); cust.CustomerAccounts.Add(NewAccount); //try //{ // foreach (Account ac in cust.CustomerAccounts) // { // if (ac.AccountNumber == AccNumber) // { // cust.CustomerAccounts.Remove(NewAccount); // return false; // } // } //} //catch (System.InvalidOperationException) { } return(true); //TODO fix return statement. }
public static bool Withdraw(Account acc, double amount) { if (acc.AccountType == "saving") { if (amount > acc.Balance || amount < 0) { return(false); } if (acc.FirstWithDraw == true) { acc.Balance -= amount; acc.FirstWithDraw = false; } else if (acc.FirstWithDraw == false) { //acc.Balance = acc.Balance - (amount - (amount * 0.2)); double bal = amount / 100; double balcalc = bal * 2; double calc = amount * 0.2; double calc2 = amount - calc; acc.Balance = acc.Balance - balcalc; } } else if (acc.AccountType == "credit") { if (acc.Balance > -5000) { CreditAccount acc2 = (CreditAccount)acc; double bal = amount / 100; double depth = bal * acc2.DeptRate; acc.Balance -= amount + depth; } } return(true); }