Initial commit

This commit is contained in:
2025-08-25 10:28:07 +02:00
commit 4c919ae5cb
5 changed files with 79 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,41 @@
"
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 >> count [
^ count
]
{ #category : #accessing }
Counter >> count: anInteger [
count := anInteger
]
{ #category : #accessing }
Counter >> decrement [
count := count - 1
]
{ #category : #accessing }
Counter >> increment [
count := count + 1
]

View File

@@ -0,0 +1,31 @@
Class {
#name : #CounterTest,
#superclass : #TestCase,
#category : #MyCounter
}
{ #category : #tests }
CounterTest >> testCountIsSetAndRead [
| c |
c := Counter new.
c count: 7.
self assert: c count equals: 7
]
{ #category : #tests }
CounterTest >> testDecrement [
| c |
c := Counter new.
c count: 2.
c decrement; decrement.
self assert: c count equals: 0
]
{ #category : #tests }
CounterTest >> testIncrement [
| c |
c := Counter new.
c count: 2.
c increment; increment.
self assert: c count equals: 4
]

1
src/MyCounter/package.st Normal file
View File

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