static void Main() { IAccount[] accounts = new IAccount[MAX_CUST]; accounts[0] = new CustomerAccount(); accounts[0].PayInFunds(100); Console.WriteLine("Balance: {0}", accounts[0].GetBalance()); accounts[1] = new BabyAccount(); accounts[1].PayInFunds(50); Console.WriteLine("Balance: {0}", accounts[1].GetBalance()); if (accounts[0].WithdrawFunds(20)) { Console.WriteLine("Withdraw OK"); } if (accounts[1].WithdrawFunds(20)) { Console.WriteLine("Withdraw OK"); } else { Console.WriteLine("Baby can withdraw max 10"); } Console.Read(); }
static void Main(string[] args) { IAccount [] accounts = new IAccount[MAX_CUST]; accounts[0] = new CustomerAccount("Phuong"); accounts[0].payInFunds(100); Console.WriteLine("Balance "+ accounts[0].Balance); accounts[1] = new BabyAccount("KKY","Nanterre"); accounts[1].payInFunds(20); accounts[1].withdrawFunds(9); accounts[1].Name = "KKYPhuong"; Console.WriteLine(accounts[0].printWarning()); Console.WriteLine(accounts[0].ToString()); Console.WriteLine(accounts[1].ToString()); Console.WriteLine(accounts[0].Equals(accounts[1])); Console.WriteLine(accounts[1].Equals(accounts[0])); //Delegate CalculateFee calc; //declare an instance of delegate calc = new CalculateFee(RipOffFee); // map/call the ripofffee method calc(-1); //execute the method calc = new CalculateFee(FriendlyFee); calc(-1); //Bank SGBank myBank = new SGBank(); myBank.storeAccount(accounts[0]); myBank.storeAccount(accounts[1]); IAccount found = myBank.findAccount("Phuong"); Console.WriteLine(found.ToString()); string d = Console.ReadLine(); }