Skip to content
Permalink
Browse files

2.3 / Create RevealingReferences class using Dictionary.

  • Loading branch information
yujihamaguchi committed Dec 28, 2019
1 parent d7ff7fe commit 0a4748d7359737b3f8d7d7ae9dfaa1b10ded77d9
@@ -0,0 +1,13 @@
Class {
#name : #RevealingReferencesTest,
#superclass : #TestCase,
#category : #'Example-OOD-Tests'
}

{ #category : #tests }
RevealingReferencesTest >> testDiameters [
| revealingReferences |
revealingReferences := RevealingReferences
data: #(#(622 20) #(622 23) #(559 30) #(559 40)).
self assert: revealingReferences diameters equals: #(662 668 619 639)
]
@@ -0,0 +1,27 @@
Class {
#name : #RevealingReferences,
#superclass : #Object,
#instVars : [
'wheels'
],
#category : #'Example-OOD'
}

{ #category : #'instance creation' }
RevealingReferences class >> data: aData [
^ self basicNew setData: aData
]

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

{ #category : #private }
RevealingReferences >> setData: aData [
wheels := aData
collect: [ :cell |
{(#rim -> (cell at: 1)).
(#tire -> (cell at: 2))} asDictionary ]
]

0 comments on commit 0a4748d

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