" 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: " Class { #name : #Counter, #superclass : #Object, #instVars : [ 'count' ], #category : #MyCounter } { #category : #accessing } Counter class >> startingAt: anInteger [ ^ self new count: anInteger ] { #category : #accessing } Counter >> count [ ^ count ] { #category : #accessing } Counter >> count: anInteger [ count := anInteger ] { #category : #operation } Counter >> decrement [ count := count - 1 ] { #category : #operation } Counter >> increment [ count := count + 1 ] { #category : #initialization } Counter >> initialize [ super initialize. count := 0 ] { #category : #accessing } Counter >> printOn: aStream [ super printOn: aStream. "a Counter" aStream nextPutAll: ' withValue: ', count printString. aStream cr ]