コード例 #1
0
ファイル: UI.cs プロジェクト: DreamEther/Revature-Project-0
        public static void CreateBusinessAccount()
        {
            Console.Clear();
            Console.WriteLine("You must sign in with your full name and pin before creating an account.");
            Console.WriteLine("Please enter your first name: ");
            string firstName = Console.ReadLine();

            UI.StringOnlyCheck(firstName);
            Console.WriteLine("Please enter your last name:");
            string lastName = Console.ReadLine();

            UI.StringOnlyCheck(lastName);
            Console.WriteLine("Please enter your unique pin number");
            string pin       = Console.ReadLine();
            int    pinNumber = UI.CheckPin(pin);

            if (AccountManager.customers.Count == 0)
            {
                Console.WriteLine("Sorry, we couldn't find any customers related to the information provided!");
                Program.ExecuteUserInput();
            }
            bool     isFound  = false;
            Customer customer = null;

            foreach (var cust in AccountManager.customers)
            {
                if (firstName.ToLower() == cust.FirstName && lastName.ToLower() == cust.LastName && pinNumber == cust.Pin)
                {
                    customer = cust;
                    isFound  = true;
                    break;
                }
            }
            if (isFound == true)
            {
                var businessAccount = new BusinessAccount();
                var generateAccount = new AccountManager(businessAccount, customer);
                Console.WriteLine("You've successfully opened up a business account with us!");
                OnEnterPress();
                Console.Clear();
                Program.ExecuteUserInput();
            }
            else
            {
                Console.Clear();
                Console.WriteLine("Sorry, we couldn't find any customers related to the information provided!");
                Program.ExecuteUserInput();
            }
        }
コード例 #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);
        }