类 ShapeSubject

java.lang.Object
com.example.graphics.observer.ShapeSubject

public class ShapeSubject extends Object
Subject class for the Observer pattern. This maintains a list of observers and notifies them of changes.
  • 字段详细资料

  • 构造器详细资料

    • ShapeSubject

      public ShapeSubject()
      Constructor initializes the observer list
  • 方法详细资料

    • addObserver

      public void addObserver(ShapeObserver observer)
      Add an observer to be notified of changes
      参数:
      observer - the observer to add
    • removeObserver

      public void removeObserver(ShapeObserver observer)
      Remove an observer from the notification list
      参数:
      observer - the observer to remove
    • notifyShapeAdded

      public void notifyShapeAdded(Shape shape)
      Notify all observers that a shape was added
      参数:
      shape - the shape that was added
    • notifyShapeRemoved

      public void notifyShapeRemoved(Shape shape)
      Notify all observers that a shape was removed
      参数:
      shape - the shape that was removed
    • notifyShapeModified

      public void notifyShapeModified(Shape shape)
      Notify all observers that a shape was modified
      参数:
      shape - the shape that was modified