更新时间:2023-02-15 17:28:37
也许对事件使用继承层次结构?
Perhaps use an inheritance hierarchy for the Events?
所以你有:
- abstract Event
-- MoveEvent(Direction)
-- FooEvent()
-- BarEvent()
可能更有意义:
- abstract Event
-- abstract MoveEvent
--- MoveUpEvent
--- MoveDownEvent
--- MoveRightEvent
--- MoveLeftEvent
-- FooEvent
-- BarEvent
如果所有的 Move 事件都有一个距离,那么将它传递给 MoveEvent 构造函数(它会向下波动).
If all the Move events have a distance, then pass that into the MoveEvent constructor (which will ripple down).