public void TransferTo(double x, Account2 b) { 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"); } }
static void Main(string[] args) { Customer2 y = new Customer2("Tan Ah Kow", "20, Seaside Road", "XXX20", new DateTime(1989, 10, 11)); Customer2 z = new Customer2("Kim Lee Keng", "2, Rich View", "XXX9F", new DateTime(1993, 4, 25)); Account2 a = new Account2("001-001-001", y, 2000); Account2 b = new Account2("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()); int n1 = y.Age; Console.WriteLine(n1); int n2 = z.Age; Console.WriteLine(n2); }