Skip to content
Permalink
Browse files

2.3 / Create RevealingReferences class using Wheel class.

  • Loading branch information
yujihamaguchi committed Dec 28, 2019
1 parent 0a4748d commit b44cd47663e949b1c9bb20878448db86e7a5f3d4
Showing with 33 additions and 5 deletions.
  1. +2 −5 src/Example-OOD/RevealingReferences.class.st
  2. +31 −0 src/Example-OOD/Wheel.class.st
@@ -14,14 +14,11 @@ RevealingReferences class >> data: aData [

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

{ #category : #private }
RevealingReferences >> setData: aData [
wheels := aData
collect: [ :cell |
{(#rim -> (cell at: 1)).
(#tire -> (cell at: 2))} asDictionary ]
collect: [ :cell | Wheel rim: (cell at: 1) tire: (cell at: 2) ]
]
@@ -0,0 +1,31 @@
Class {
#name : #Wheel,
#superclass : #Object,
#instVars : [
'rim',
'tire'
],
#category : #'Example-OOD'
}

{ #category : #'instance creation' }
Wheel class >> rim: rimInteger tire: tireFloat [
^ self basicNew setRim: rimInteger tire: tireFloat
]

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

{ #category : #private }
Wheel >> setRim: rimInteger tire: tireFloat [
rim := rimInteger .
tire := tireFloat .
^ self
]

{ #category : #accessing }
Wheel >> tire [
^ tire
]

0 comments on commit b44cd47

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