Beispiel #1
0
 public bool TransferTo(double amount, BankAccount2 another)
 {
     if (Balance > amount)
     {
         another.Deposit(amount);
         Balance = Balance - amount;
         Console.WriteLine("Successfully Transfered");
         return(true);
     }
     else
     {
         Console.WriteLine("You don't have sufficient funds to transfer");
         return(false);
     }
 }
        public static void Main()
        {
            Customer     y = new Customer("Tan Ah Kow", "20, Seaside Road", "XXX20", new DateTime(1989, 10, 11));
            Customer     z = new Customer("Kim Lee Keng", "2, Rich View", "XXX9F", new DateTime(1993, 4, 25));
            BankAccount2 a = new BankAccount2("001-001-001", y, 2000);
            BankAccount2 b = new BankAccount2("001-001-002", z, 5000);

            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());
            Console.WriteLine(y.Age);
        }