diff --git a/src/MyCounter/CounterTest.class.st b/src/MyCounter-Tests/CounterTest.class.st similarity index 88% rename from src/MyCounter/CounterTest.class.st rename to src/MyCounter-Tests/CounterTest.class.st index 9333c95..99d9148 100644 --- a/src/MyCounter/CounterTest.class.st +++ b/src/MyCounter-Tests/CounterTest.class.st @@ -4,7 +4,7 @@ This class contains tests for the Counter class Class { #name : #CounterTest, #superclass : #TestCase, - #category : #MyCounter + #category : #'MyCounter-Tests' } { #category : #tests } diff --git a/src/MyCounter-Tests/package.st b/src/MyCounter-Tests/package.st new file mode 100644 index 0000000..fb1564a --- /dev/null +++ b/src/MyCounter-Tests/package.st @@ -0,0 +1 @@ +Package { #name : #'MyCounter-Tests' } diff --git a/src/MyCounter/Counter.class.st b/src/MyCounter/Counter.class.st index 09ef545..8a0ac10 100644 --- a/src/MyCounter/Counter.class.st +++ b/src/MyCounter/Counter.class.st @@ -16,6 +16,11 @@ Class { #category : #MyCounter } +{ #category : #accessing } +Counter class >> startingAt: val [ + ^ self new count: val; yourself +] + { #category : #accessing } Counter >> count [ "returns the current count" @@ -29,3 +34,29 @@ Counter >> count: val [ ^ val ] + +{ #category : #API } +Counter >> decrement [ + "decrease the value of count by 1" + count := count - 1. + ^ self +] + +{ #category : #API } +Counter >> increment [ + "updates the count by 1" + count := count + 1. + ^ self +] + +{ #category : #initialization } +Counter >> initialize [ + "Set the initial value to 0" + count := 0 +] + +{ #category : #printing } +Counter >> printOn: aStream [ + super printOn: aStream. + aStream nextPutAll: ' with value: ', count printString. +]