static void Main()
        {
            IAccount vGoldAccount  = new GoldAccount();
            IAccount vSaverAccount = new SaverAccount();

            ITransferAccount vCurAccount = new CurrentAccount();

            vGoldAccount.Credit(10000);
            vSaverAccount.Credit(100);

            Console.WriteLine($"Gold Account Balance {vGoldAccount.Balance,6:C}");
            Console.WriteLine(vSaverAccount.ToString());

            vSaverAccount.Debit(1000);


            IAccount[] allAccounts = new IAccount[2];
            allAccounts[0] = vGoldAccount;
            allAccounts[1] = vSaverAccount;

            //Dividend...
            foreach (IAccount Acc in allAccounts)
            {
                Acc.Credit(10);
            }


            vCurAccount.Transfer(vSaverAccount, vCurAccount);
        }
Exemple #2
0
 static void Main()
 {
     IBankAccount venusAccount = new SaverAccount();
      ITransferBankAccount jupiterAccount = new CurrentAccount();
      venusAccount.PayIn(200);
      jupiterAccount.PayIn(500);
      jupiterAccount.TransferTo(venusAccount, 100);
      Console.WriteLine(venusAccount.ToString());
      Console.WriteLine(jupiterAccount.ToString());
 }
Exemple #3
0
        static void Main()
        {
            IBankAccount         venusAccount   = new SaverAccount();
            ITransferBankAccount jupiterAccount = new CurrentAccount();

            venusAccount.PayIn(200);
            jupiterAccount.PayIn(500);
            jupiterAccount.TransferTo(venusAccount, 100);
            Console.WriteLine(venusAccount.ToString());
            Console.WriteLine(jupiterAccount.ToString());
        }
Exemple #4
0
 static void Main()
 {
     IBankAccount venusAccount = new SaverAccount();
      IBankAccount jupiterAccount = new GoldAccount();
      venusAccount.PayIn(200);
      venusAccount.Withdraw(100);
      Console.WriteLine(venusAccount.ToString());
      jupiterAccount.PayIn(500);
      jupiterAccount.Withdraw(600);
      jupiterAccount.Withdraw(100);
      Console.WriteLine(jupiterAccount.ToString());
 }
Exemple #5
0
        static void Main()
        {
            IBankAccount venusAccount   = new SaverAccount();
            IBankAccount jupiterAccount = new GoldAccount();

            venusAccount.PayIn(200);
            venusAccount.Withdraw(100);
            Console.WriteLine(venusAccount.ToString());
            jupiterAccount.PayIn(500);
            jupiterAccount.Withdraw(600);
            jupiterAccount.Withdraw(100);
            Console.WriteLine(jupiterAccount.ToString());
        }
Exemple #6
0
        static void Main(string[] args)
        {
            IBankAccount venusAccount = new SaverAccount();
            ITransferBankAccount jupiterAccount = new CurrentAccount();
            venusAccount.PayIn(200);

            Console.WriteLine(venusAccount.ToString());
            jupiterAccount.PayIn(500);
            jupiterAccount.PayIn(400);
            jupiterAccount.Withdraw(500);
            jupiterAccount.Withdraw(100);
            Console.WriteLine(jupiterAccount.ToString());
            bool isTrans = jupiterAccount.TransferTo(venusAccount, 300);
            if (isTrans)
            {
                Console.WriteLine("转账后:" + jupiterAccount.ToString());
                Console.WriteLine("转账后: " + venusAccount.ToString());
            }
            else
            {
                Console.WriteLine("转账失败");
            }
            Console.Read();
        }
Exemple #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            IBankAccount venusAccount   = new SaverAccount();
            IBankAccount jupiterAccount = new GoldAccount();

            venusAccount.PayIn(200);
            venusAccount.Withdraw(100);

            Console.WriteLine(venusAccount.ToString());

            jupiterAccount.PayIn(500);
            jupiterAccount.Withdraw(600);
            jupiterAccount.Withdraw(100);

            Console.WriteLine(jupiterAccount.ToString());
        }
        static void Main(string[] args)
        {
            IBankAccount saver = new SaverAccount();
            IBankAccount gold  = new GoldAccount();

            try
            {
                Console.WriteLine("First count:");
                Console.WriteLine($"Number of Gold Accounts: {GoldAccount.NumOfAccounts}");
                Console.WriteLine($"Number of Saver Accounts: {SaverAccount.NumOfAccounts}");

                IBankAccount saver1 = new SaverAccount();
                IBankAccount gold1  = new GoldAccount();

                Console.WriteLine("Second count:");
                Console.WriteLine($"Number of Gold Accounts: {GoldAccount.NumOfAccounts}");
                Console.WriteLine($"Number of Saver Accounts: {SaverAccount.NumOfAccounts}");

                gold1  = null;
                saver1 = null;

                GC.Collect();

                Console.WriteLine("After null:");
                Console.WriteLine($"Number of Gold Accounts: {GoldAccount.NumOfAccounts}");
                Console.WriteLine($"Number of Saver Accounts: {SaverAccount.NumOfAccounts}");

                saver.Deposit(1250.75M);
                saver.Withdraw(700.50M);

                gold.Deposit(5000.38M);
                gold.Withdraw(5678.90M);
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.WriteLine($"after withdrawal of $700.50...{saver.ToString()}");
                Console.WriteLine($"after (failed)withdrawal of $5678.90...{gold.ToString()}");
            }
        }
        static void Main(string[] args)
        {
            IBankAccount saver = new SaverAccount();
            IBankAccount gold  = new GoldAccount();

            try
            {
                saver.Deposit(1250.75M);
                saver.Withdraw(700.50M);

                gold.Deposit(5000.38M);
                gold.Withdraw(5678.90M);
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.WriteLine($"after withdrawal of $700.50...{saver.ToString()}");
                Console.WriteLine($"after (failed)withdrawal of $5678.90...{gold.ToString()}");
            }
        }