Worked through, added tests for everything
This commit is contained in:
parent
bf91d19a0e
commit
de470d6c33
@ -4,7 +4,7 @@ This class contains tests for the Counter class
|
||||
Class {
|
||||
#name : #CounterTest,
|
||||
#superclass : #TestCase,
|
||||
#category : #MyCounter
|
||||
#category : #'MyCounter-Tests'
|
||||
}
|
||||
|
||||
{ #category : #tests }
|
||||
1
src/MyCounter-Tests/package.st
Normal file
1
src/MyCounter-Tests/package.st
Normal file
@ -0,0 +1 @@
|
||||
Package { #name : #'MyCounter-Tests' }
|
||||
@ -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.
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user