类 ShapeSubject
java.lang.Object
com.example.graphics.observer.ShapeSubject
Subject class for the Observer pattern.
This maintains a list of observers and notifies them of changes.
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
addObserver
(ShapeObserver observer) Add an observer to be notified of changesvoid
notifyShapeAdded
(Shape shape) Notify all observers that a shape was addedvoid
notifyShapeModified
(Shape shape) Notify all observers that a shape was modifiedvoid
notifyShapeRemoved
(Shape shape) Notify all observers that a shape was removedvoid
removeObserver
(ShapeObserver observer) Remove an observer from the notification list
-
字段详细资料
-
observers
-
-
构造器详细资料
-
ShapeSubject
public ShapeSubject()Constructor initializes the observer list
-
-
方法详细资料
-
addObserver
Add an observer to be notified of changes- 参数:
observer
- the observer to add
-
removeObserver
Remove an observer from the notification list- 参数:
observer
- the observer to remove
-
notifyShapeAdded
Notify all observers that a shape was added- 参数:
shape
- the shape that was added
-
notifyShapeRemoved
Notify all observers that a shape was removed- 参数:
shape
- the shape that was removed
-
notifyShapeModified
Notify all observers that a shape was modified- 参数:
shape
- the shape that was modified
-