public Account3(string a, Customer3 b, double x, double y = 0) //If there are parameters { acc_Number = a; acc_Name = b.Acc_Name; balance = x; interestRate = y; }
//Constructor public CurrentAccount3(string a, Customer3 b, double x, double y = 0.25) : base(a, b, x, y) { //Check if negative balance. if (x < 0) { Console.WriteLine("ERROR: The balance inputed is below $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()); }
public OverdraftAccount3(string a, Customer3 b, double x, double y = 0.25, double z = 6) : base(a, b, x, y) { negativeInterestRate = z; }