예제 #1
0
        public override void TransferTo(double x, Account3 b)
        {
            //Deduct from account
            Balance = Balance - x;

            //Add to target account
            b.Deposit(x);
        }
예제 #2
0
        public virtual void TransferTo(double x, Account3 b)
        {
            if (balance > 0)
            {
                if (balance > x)
                {
                    //Deduct from A
                    this.balance = balance - x;

                    //Add to accnt B
                    b.Deposit(x);
                }
                else
                {
                    Console.WriteLine("Error. Your balance is less than the transfered amount");
                }
            }
            else
            {
                Console.WriteLine("ERROR: The balance inputed is below $0.");
            }
        }
예제 #3
0
        //Play around with it.
        static void Main(string[] args)
        {
            Customer3 y = new Customer3("Tan Ah Kow", "20, Seaside Road", "XXX20", new DateTime(1989, 10, 11));
            Customer3 z = new Customer3("Kim Lee Keng", "2, Rich View", "XXX9F", new DateTime(1993, 4, 25));
            Account3  a = new Account3("001-001-001", y, 2000, 2.0);
            Account3  b = new Account3("001-001-002", z, 5000, 1.0);

            Console.WriteLine(a.Show());
            Console.WriteLine(b.Show());
            a.Deposit(100);
            Console.WriteLine(a.Show());
            a.Withdraw(200);
            Console.WriteLine(a.Show());
            a.TransferTo(300, b);
            Console.WriteLine(a.Show());
            Console.WriteLine(b.Show());

            int n1 = y.GetAge();

            Console.WriteLine(n1);
            int n2 = z.GetAge();

            Console.WriteLine(n2);

            Customer3 zy = new Customer3("Kim Lee Keng", "2, Rich View", "XXX9F", new DateTime(1993, 4, 25));
            Account3  c  = new SavingsAccount3("001-001-002", zy, -1000);
            Account3  d  = new CurrentAccount3("001-001-002", zy, -1000);
            Account3  e  = new OverdraftAccount3("001-001-002", zy, -1000);

            c.CalculateInterest();
            d.CalculateInterest();
            e.CalculateInterest();
            string n = e.Acc_Name;

            Console.WriteLine(n);
            Console.WriteLine(e.Show());
        }