Skip to content
Permalink
Browse files

2.3 / Refactor Gear class. Have a instance variable of Wheel class to…

… delegate calculating of diameter to it.
  • Loading branch information
yujihamaguchi committed Dec 29, 2019
1 parent 454a497 commit c9d8b6f11686585174924c986714a0db3a22daf2
Showing with 3 additions and 5 deletions.
  1. +3 −5 src/Example-OOD/Gear.class.st
@@ -4,8 +4,7 @@ Class {
#instVars : [
'chainring',
'cog',
'rim',
'tire'
'wheel'
],
#category : #'Example-OOD'
}
@@ -17,7 +16,7 @@ Gear class >> chainring: chainringInteger cog: cogInteger rim: rimInteger tire:

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

{ #category : #calculating }
@@ -29,7 +28,6 @@ Gear >> ratio [
Gear >> setChainring: chainringInteger cog: cogInteger rim: rimInteger tire: tireFloat [
chainring := chainringInteger.
cog := cogInteger.
rim := rimInteger .
tire := tireFloat .
wheel := Wheel rim: rimInteger tire: tireFloat .
^ self
]

0 comments on commit c9d8b6f

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