commit bf91d19a0ebd8010921af2198132f45cfcda6a76 Author: Peter Hart Date: Sat Feb 6 17:50:04 2021 -0500 Initial version with test, no increment/decrement yet diff --git a/.project b/.project new file mode 100644 index 0000000..81083cc --- /dev/null +++ b/.project @@ -0,0 +1,3 @@ +{ + 'srcDirectory' : 'src' +} \ No newline at end of file diff --git a/src/.properties b/src/.properties new file mode 100644 index 0000000..ad0471d --- /dev/null +++ b/src/.properties @@ -0,0 +1,3 @@ +{ + #format : #tonel +} \ No newline at end of file diff --git a/src/MyCounter/Counter.class.st b/src/MyCounter/Counter.class.st new file mode 100644 index 0000000..09ef545 --- /dev/null +++ b/src/MyCounter/Counter.class.st @@ -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 + +] diff --git a/src/MyCounter/CounterTest.class.st b/src/MyCounter/CounterTest.class.st new file mode 100644 index 0000000..9333c95 --- /dev/null +++ b/src/MyCounter/CounterTest.class.st @@ -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. +] diff --git a/src/MyCounter/package.st b/src/MyCounter/package.st new file mode 100644 index 0000000..242e6c9 --- /dev/null +++ b/src/MyCounter/package.st @@ -0,0 +1 @@ +Package { #name : #MyCounter }