package org.goldonship.designpattern.behavioral.observer;

import java.util.ArrayList;
import java.util.List;


public abstract class AbstractSubject implements ISubject {
    private List<IObserver> observers = new ArrayList<>();

    @Override
    public void register(IObserver observer) {
        observers.add(observer);
    }

    @Override
    public void unregister(IObserver observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObservers() {
        for (IObserver observer : observers) {
            observer.update(this);
        }
    }
}
