public Account(long id, AccountsType type, string number, DateTime openingDate, string personId)
 {
     Id          = id;
     Type        = type;
     Number      = number;
     OpeningDate = openingDate;
     Closed      = false;
     PersonId    = personId;
     Blocked     = false;
 }
Example #2
0
        public Account CreateAccount(AccountsType accountType)
        {
            Account account  = null;
            double  percent  = .1 + ((.3 - .1) * getrandom.NextDouble());
            decimal interest = (decimal)(Math.Round(percent, 2) * 100); //to generate random interest rate

            switch (accountType)
            {
            case AccountsType.Checking:
                account = new CheckingAccount();
                account.InterestRate = interest;
                break;

            case AccountsType.Business:
                account = new BusinessAccount();
                account.InterestRate = interest;
                break;

            case AccountsType.Loan:
                decimal loan = GetLoanPrompt();
                if (loan != 0)
                {
                    account = new LoanAccount(loan);
                }
                account.InterestRate = interest;
                break;

            case AccountsType.Term_Deposit:
                int years = MaturityYears();
                if (years != 0)
                {
                    account = new TermDepositAccount(years);
                }
                account.InterestRate = interest;
                break;

            default:

                break;
            }
            return(account);
        }