public void AddChild(IProfitable profitable) { if (profitable is Store) { StoreList.Add(profitable); } }
public void RemoveChild(IProfitable profitable) { if (profitable is Store) { StoreList.Remove(profitable); } }
public void RemoveChild(IProfitable profitable) { if (profitable is City) { CityList.Remove(profitable); } }
public void AddChild(IProfitable profitable) { if (profitable is City) { CityList.Add(profitable); } }
private static void PayAnnualInterest(Account[] accounts) { foreach (Account acc in accounts) { IProfitable p = acc as IProfitable; p?.AddInterest(1); //if(p != null) p.AddInterest(1) } }
private static void PayAnnualInterest(Account[] accounts) { foreach (Account acc in accounts) { IProfitable p = acc as IProfitable; if (p != null) { double interest = p.GetInterest(12); acc.Deposit(interest); } } }
private static void PayAnnualInterest(Account[] group) { foreach (var acc in group) { IProfitable p = acc as IProfitable; if (p != null) { double i = p.GetInterest(1); acc.Deposit(i); } } }
public void RemoveChild(IProfitable profitable) { throw new NotImplementedException(); }