pharo-mooc/src/MyCounter/Counter.class.st

32 lines
514 B
Smalltalk

"
Counter is a simple concrete class which supports incrementing and decrementing a counter.
Its API is
- decrement, increment
- count
Its creation API is message startingAt: match: startingAt:
"
Class {
#name : #Counter,
#superclass : #Object,
#instVars : [
'count'
],
#category : #MyCounter
}
{ #category : #accessing }
Counter >> count [
"returns the current count"
^ count
]
{ #category : #accessing }
Counter >> count: val [
"sets the counter to a specific value"
count := val.
^ val
]