Trapped-Counter.st 471 B

123456789101112131415161718192021222324252627282930313233
  1. Smalltalk createPackage: 'Trapped-Counter'!
  2. Object subclass: #TrappedCounter
  3. instanceVariableNames: 'value'
  4. package: 'Trapped-Counter'!
  5. !TrappedCounter methodsFor: 'accessing'!
  6. value
  7. ^value
  8. !
  9. value: aNumber
  10. value := aNumber
  11. ! !
  12. !TrappedCounter methodsFor: 'action'!
  13. decrement
  14. value := value - 1
  15. !
  16. increment
  17. value := value + 1
  18. ! !
  19. !TrappedCounter methodsFor: 'initialization'!
  20. initialize
  21. super initialize.
  22. SimpleAxon new registerIn: self.
  23. value := 0
  24. ! !