예제 #1
0
        static void Main(string[] args)
        {
            BankAccount checkingAccount   = new CheckingAccount();
            BankAccount savingsAccount    = new SavingsAccount();
            BankAccount secondSavingsAcct = new SavingsAccount();

            BankCustomer jayGatsby = new BankCustomer();

            jayGatsby.AddAccount(checkingAccount);
            jayGatsby.AddAccount(savingsAccount);
            jayGatsby.AddAccount(secondSavingsAcct);

            Console.WriteLine($"Jay Gatsby has {jayGatsby.Accounts.Length} accounts.");

            checkingAccount.AccountNumber   = "Checking";
            savingsAccount.AccountNumber    = "Savings";
            secondSavingsAcct.AccountNumber = "Second Savings";

            foreach (var item in jayGatsby.Accounts)
            {
                Console.WriteLine($"Account Number: {item.AccountNumber}");
            }

            checkingAccount.Deposit(2000M);
            savingsAccount.Deposit(2000M);
            secondSavingsAcct.Deposit(1500M);

            foreach (var item in jayGatsby.Accounts)
            {
                Console.WriteLine($"Account Name: {item.AccountNumber} - Account Balance: {item.Balance.ToString("C")}");
            }

            checkingAccount.Withdraw(500.00M);
            savingsAccount.Withdraw(1000M);

            foreach (var item in jayGatsby.Accounts)
            {
                Console.WriteLine($"Account Name: {item.AccountNumber} - Account Balance: {item.Balance.ToString("C")}");
            }
            Console.WriteLine("IsVIP: " + jayGatsby.IsVIP);


            savingsAccount.Transfer(checkingAccount, 40.00M);
            Console.WriteLine($"Checking: {checkingAccount.Balance}, Savings: {savingsAccount.Balance}");
            Console.ReadKey();
        }
예제 #2
0
파일: Program.cs 프로젝트: tiasmith8/week3
        static void Main(string[] args)
        {
            Console.WriteLine($"Welcome to the Bank Account Application");

            BankCustomer PopPop = new BankCustomer();

            ///instantiate newAccount1
            BankAccount donorAccount = new BankAccount();

            ///intantiate newAccount2
            BankAccount receiverAccount = new BankAccount();

            ///add money to both accounts using deposit method
            donorAccount.Deposit(100M);
            receiverAccount.Deposit(100M);

            CheckingAccount checkingAccount_GeorgeMichael = new CheckingAccount();

            ///write out amount $$$ in each
            Console.WriteLine($"Balance of donorAccount: ${donorAccount.Balance:C2} | Balance of Receiver Account: ${receiverAccount.Balance}");

            ///transfer $$$ from new Account 1 to new Account 2
            donorAccount.Transfer(receiverAccount, 50M);

            //////write out amount $$$ in each after transfer
            Console.WriteLine($"Balance of donorAccount: {donorAccount.Balance:C2} | ${receiverAccount.Balance}");

            // test out withdraw and overdraft scenarios
            decimal overDrawMoneyTest = checkingAccount_GeorgeMichael.Withdraw(90M);

            //get new balance and print out
            Console.WriteLine($"This the account balance: {checkingAccount_GeorgeMichael.Balance:C2}");

            //Create new savings account
            SavingsAccount brandNewSavingAccountForSomeone = new SavingsAccount();

            //Add $149 to the savings account
            brandNewSavingAccountForSomeone.Deposit(-190);

            //Print new balance
            Console.WriteLine($"Balance for savings account: {brandNewSavingAccountForSomeone.Balance:C2}");

            //Test withdraw for savings account
            brandNewSavingAccountForSomeone.Withdraw(90);
            Console.WriteLine($"Balance for savings account after withdrawing $490: {brandNewSavingAccountForSomeone.Balance:C2}");
        }