-
Notifications
You must be signed in to change notification settings - Fork 65
/
ShootoutChameneosColour.class.st
148 lines (124 loc) · 3.17 KB
/
ShootoutChameneosColour.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
Class {
#name : #ShootoutChameneosColour,
#superclass : #Object,
#instVars : [
'color'
],
#classVars : [
'Blue',
'Red',
'Yellow'
],
#category : #'CogBenchmarks-Shootout'
}
{ #category : #accessing }
ShootoutChameneosColour class >> blue [
^Blue
]
{ #category : #accessing }
ShootoutChameneosColour class >> blue: anObject [
Blue := anObject
]
{ #category : #'initialize-release' }
ShootoutChameneosColour class >> createBlue [
"comment stating purpose of message"
^super new color: #blue
]
{ #category : #'initialize-release' }
ShootoutChameneosColour class >> createRed [
"comment stating purpose of message"
^super new color: #red
]
{ #category : #'initialize-release' }
ShootoutChameneosColour class >> createYellow [
"comment stating purpose of message"
^super new color: #yellow
]
{ #category : #printing }
ShootoutChameneosColour class >> generateReportOfColoursOn: readOut [
| colours |
colours := Array
with: Blue
with: Red
with: Yellow.
colours do:
[:aColour |
colours do:
[:anotherColour |
aColour printOn: readOut.
readOut nextPutAll: ' + '.
anotherColour printOn: readOut.
readOut nextPutAll: ' -> '.
(aColour complementaryColourFor: anotherColour) printOn: readOut.
readOut nl]].
^readOut
]
{ #category : #'initialize-release' }
ShootoutChameneosColour class >> initialize [
"self initialize"
Red := self createRed.
Blue := self createBlue.
Yellow := self createYellow
]
{ #category : #accessing }
ShootoutChameneosColour class >> red [
^Red
]
{ #category : #accessing }
ShootoutChameneosColour class >> red: anObject [
Red := anObject
]
{ #category : #accessing }
ShootoutChameneosColour class >> yellow [
^Yellow
]
{ #category : #accessing }
ShootoutChameneosColour class >> yellow: anObject [
Yellow := anObject
]
{ #category : #accessing }
ShootoutChameneosColour >> color [
^color
]
{ #category : #accessing }
ShootoutChameneosColour >> color: aColor [
color := aColor
]
{ #category : #'as yet unclassified' }
ShootoutChameneosColour >> complementaryColourFor: aChameneosColour [
"determine the complementary colour defined as..."
self == aChameneosColour ifTrue: [^self].
self isBlue
ifTrue:
[aChameneosColour isRed
ifTrue: [^self class yellow]
ifFalse: [^self class red]].
self isRed
ifTrue:
[aChameneosColour isBlue
ifTrue: [^self class yellow]
ifFalse: [^self class blue]].
aChameneosColour isBlue
ifTrue: [^self class red]
ifFalse: [^self class blue]
]
{ #category : #testing }
ShootoutChameneosColour >> hasSameColorAs: aChameneos [
^self color == aChameneos color
]
{ #category : #testing }
ShootoutChameneosColour >> isBlue [
^self == self class blue
]
{ #category : #testing }
ShootoutChameneosColour >> isRed [
^self == self class red
]
{ #category : #testing }
ShootoutChameneosColour >> isYellow [
^self == self class yellow
]
{ #category : #printing }
ShootoutChameneosColour >> printOn: aStream [
aStream nextPutAll: self color
]