Initial version with test, no increment/decrement yet
This commit is contained in:
commit
bf91d19a0e
3
src/.properties
Normal file
3
src/.properties
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
#format : #tonel
|
||||
}
|
||||
31
src/MyCounter/Counter.class.st
Normal file
31
src/MyCounter/Counter.class.st
Normal file
@ -0,0 +1,31 @@
|
||||
"
|
||||
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
|
||||
|
||||
]
|
||||
16
src/MyCounter/CounterTest.class.st
Normal file
16
src/MyCounter/CounterTest.class.st
Normal file
@ -0,0 +1,16 @@
|
||||
"
|
||||
This class contains tests for the Counter class
|
||||
"
|
||||
Class {
|
||||
#name : #CounterTest,
|
||||
#superclass : #TestCase,
|
||||
#category : #MyCounter
|
||||
}
|
||||
|
||||
{ #category : #tests }
|
||||
CounterTest >> testCountIsSetAndRead [
|
||||
| c |
|
||||
c := Counter new.
|
||||
c count: 7.
|
||||
self assert: c count equals: 7.
|
||||
]
|
||||
1
src/MyCounter/package.st
Normal file
1
src/MyCounter/package.st
Normal file
@ -0,0 +1 @@
|
||||
Package { #name : #MyCounter }
|
||||
Loading…
x
Reference in New Issue
Block a user