Initial version with test, no increment/decrement yet

This commit is contained in:
Peter Hart 2021-02-06 17:50:04 -05:00
commit bf91d19a0e
5 changed files with 54 additions and 0 deletions

3
.project Normal file
View File

@ -0,0 +1,3 @@
{
'srcDirectory' : 'src'
}

3
src/.properties Normal file
View File

@ -0,0 +1,3 @@
{
#format : #tonel
}

View 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
]

View 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
View File

@ -0,0 +1 @@
Package { #name : #MyCounter }