-
Notifications
You must be signed in to change notification settings - Fork 68
/
ShootoutCreature.class.st
77 lines (65 loc) · 1.47 KB
/
ShootoutCreature.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
Class {
#name : #ShootoutCreature,
#superclass : #Object,
#instVars : [
'creatureName',
'colour',
'selfMet',
'creaturesMet'
],
#category : #'CogBenchmarks-Shootout'
}
{ #category : #'initialize-release' }
ShootoutCreature class >> withName: aName colour: aColour [
^(ShootoutCreature new initialize)
name: aName;
colour: aColour
]
{ #category : #accessing }
ShootoutCreature >> colour [
^colour
]
{ #category : #accessing }
ShootoutCreature >> colour: anObject [
colour := anObject
]
{ #category : #accessing }
ShootoutCreature >> creaturesMet [
^creaturesMet
]
{ #category : #accessing }
ShootoutCreature >> creaturesMet: anObject [
creaturesMet := anObject
]
{ #category : #'initialize-release' }
ShootoutCreature >> initialize [
selfMet := 0.
creaturesMet := 0
]
{ #category : #accessing }
ShootoutCreature >> name [
^creatureName
]
{ #category : #accessing }
ShootoutCreature >> name: anObject [
creatureName := anObject
]
{ #category : #accessing }
ShootoutCreature >> selfMet [
^selfMet
]
{ #category : #accessing }
ShootoutCreature >> selfMet: anObject [
^selfMet := anObject
]
{ #category : #controlling }
ShootoutCreature >> visitMall: mall [
[| partner |
partner := mall visitWith: self.
partner ifNotNil:
[colour := colour complementaryColourFor: partner colour.
self == partner ifTrue: [selfMet := selfMet + 1].
creaturesMet := creaturesMet + 1].
partner isNil]
whileFalse
]