Initial commit
This commit is contained in:
3
src/.properties
Normal file
3
src/.properties
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
#format : #tonel
|
||||||
|
}
|
41
src/MyCounter/Counter.class.st
Normal file
41
src/MyCounter/Counter.class.st
Normal 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
|
||||||
|
]
|
31
src/MyCounter/CounterTest.class.st
Normal file
31
src/MyCounter/CounterTest.class.st
Normal 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
1
src/MyCounter/package.st
Normal file
@@ -0,0 +1 @@
|
|||||||
|
Package { #name : #MyCounter }
|
Reference in New Issue
Block a user