public class BankAccount
{
ArrayList<IAccountObserver> observerList = new ArrayList<IAccountObserver>();
public void Withdraw(int data)
{
//...
}
public void Notify(UserAccountArgs args)
{
foreach (IAccountObserver observer in observerList)
{
observer.Update(args);
}
}
public void AddObserver(IAccountObserver observer)
{
observerList.Add(observer);
}
public void RemoveObserver(IAccountObserver observer)
{
observerList.Remove(observer);
}
}