Skip to content
Permalink
Browse files

2.2 / Create Gear class.

  • Loading branch information
yujihamaguchi committed Dec 28, 2019
0 parents commit 00f7036ee3b9ee03af9e73f8f6dd713454609fb6
@@ -0,0 +1,3 @@
{
'srcDirectory' : 'src'
}
@@ -0,0 +1,3 @@
{
#format : #tonel
}
@@ -0,0 +1,15 @@
Class {
#name : #GearTest,
#superclass : #TestCase,
#category : #'Example-OOD-Tests'
}

{ #category : #tests }
GearTest >> testRatio [
self
assert: (Gear chainring: 52 cog: 11) ratio
equals: 4.7272727272727275.
self
assert: (Gear chainring: 30 cog: 27) ratio
equals: 1.1111111111111112
]
@@ -0,0 +1 @@
Package { #name : #'Example-OOD-Tests' }
@@ -0,0 +1,26 @@
Class {
#name : #Gear,
#superclass : #Object,
#instVars : [
'chainring',
'cog'
],
#category : #'Example-OOD'
}

{ #category : #'instance creation' }
Gear class >> chainring: chainringInteger cog: cogInteger [
^ self basicNew setChainring: chainringInteger cog: cogInteger .
]

{ #category : #calculating }
Gear >> ratio [
^ chainring / cog asFloat
]

{ #category : #private }
Gear >> setChainring: chainringInteger cog: cogInteger [
chainring := chainringInteger.
cog := cogInteger.
^ self
]
@@ -0,0 +1 @@
Package { #name : #'Example-OOD' }

0 comments on commit 00f7036

Please sign in to comment.
You can’t perform that action at this time.