Skip to content
Permalink
Browse files

2.3 / Refactor RevealingReferences class. Create 'diameter' selector …

…to delegate calculating of diameter for a wheel.
  • Loading branch information
yujihamaguchi committed Dec 28, 2019
1 parent b44cd47 commit 454a49751ea076bdf7bec5695060af65ff277e40
@@ -0,0 +1,14 @@
Class {
#name : #WheelTest,
#superclass : #TestCase,
#category : #'Example-OOD-Tests'
}

{ #category : #tests }
WheelTest >> testDiameter [
self assert: (Wheel rim: 622 tire: 20) diameter equals: 662.
self assert: (Wheel rim: 622 tire: 23) diameter equals: 668.
self assert: (Wheel rim: 559 tire: 30) diameter equals: 619.
self assert: (Wheel rim: 559 tire: 40) diameter equals: 639

]
@@ -14,7 +14,7 @@ RevealingReferences class >> data: aData [

{ #category : #calculating }
RevealingReferences >> diameters [
^ wheels collect: [ :wheel | wheel rim + (wheel tire * 2) ]
^ wheels collect: [ :wheel | wheel diameter ]
]

{ #category : #private }
@@ -13,6 +13,11 @@ Wheel class >> rim: rimInteger tire: tireFloat [
^ self basicNew setRim: rimInteger tire: tireFloat
]

{ #category : #calculating }
Wheel >> diameter [
^ rim + (tire * 2)
]

{ #category : #accessing }
Wheel >> rim [
^ rim

0 comments on commit 454a497

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