Skip to content
Permalink
Browse files

2.2 / Add gearInches selector to Gear class.

  • Loading branch information
yujihamaguchi committed Dec 28, 2019
1 parent 00f7036 commit cb9cab740ccca0929423bcd0491460f709832006
Showing with 20 additions and 4 deletions.
  1. +7 −0 src/Example-OOD-Tests/GearTest.class.st
  2. +13 −4 src/Example-OOD/Gear.class.st
@@ -4,6 +4,13 @@ Class {
#category : #'Example-OOD-Tests'
}

{ #category : #tests }
GearTest >> testGearInches [
self assert: (Gear chainring: 52 cog: 11 rim: 26 tire: 1.5) gearInches equals: 137.0909090909091.
self assert: (Gear chainring: 52 cog: 11 rim: 24 tire: 1.25) gearInches equals: 125.27272727272728

]

{ #category : #tests }
GearTest >> testRatio [
self
@@ -3,14 +3,21 @@ Class {
#superclass : #Object,
#instVars : [
'chainring',
'cog'
'cog',
'rim',
'tire'
],
#category : #'Example-OOD'
}

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

{ #category : #calculating }
Gear >> gearInches [
^ self ratio * (rim + (tire * 2))
]

{ #category : #calculating }
@@ -19,8 +26,10 @@ Gear >> ratio [
]

{ #category : #private }
Gear >> setChainring: chainringInteger cog: cogInteger [
Gear >> setChainring: chainringInteger cog: cogInteger rim: rimInteger tire: tireFloat [
chainring := chainringInteger.
cog := cogInteger.
rim := rimInteger .
tire := tireFloat .
^ self
]

0 comments on commit cb9cab7

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