Trapped-Counter.st 886 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. Smalltalk createPackage: 'Trapped-Counter'!
  2. (Smalltalk packageAt: 'Trapped-Counter' ifAbsent: [ self error: 'Package not created: Trapped-Counter' ]) imports: {'trapped/Trapped-Processors'}!
  3. Object subclass: #CounterApp
  4. instanceVariableNames: ''
  5. package: 'Trapped-Counter'!
  6. !CounterApp methodsFor: 'startup'!
  7. start
  8. | model |
  9. model := TrappedCounter new.
  10. model axxord: SimpleAxon new.
  11. Trapped start: { model }
  12. ! !
  13. !CounterApp class methodsFor: 'startup'!
  14. start
  15. ^ self new start
  16. ! !
  17. Object subclass: #TrappedCounter
  18. instanceVariableNames: 'value'
  19. package: 'Trapped-Counter'!
  20. !TrappedCounter methodsFor: 'accessing'!
  21. value
  22. ^value
  23. !
  24. value: aNumber
  25. value := aNumber
  26. ! !
  27. !TrappedCounter methodsFor: 'action'!
  28. decrement
  29. value := value - 1
  30. !
  31. increment
  32. value := value + 1
  33. ! !
  34. !TrappedCounter methodsFor: 'initialization'!
  35. initialize
  36. super initialize.
  37. value := 0
  38. ! !