[Pharo] Personal fitness tracker web app.
Update core domain objects.
Changed files
- src/MyFitnessTracker-Core-Tests/MFTRoutineTest.class.st
- src/MyFitnessTracker-Core-Tests/MFTWorkoutPrescriptionTest.class.st
- src/MyFitnessTracker-Core/MFTRoutine.class.st
- src/MyFitnessTracker-Core/MFTTrainee.class.st
- src/MyFitnessTracker-Core/MFTWorkoutLog.class.st
- src/MyFitnessTracker-Core/MFTWorkoutPrescription.class.st
src/MyFitnessTracker-Core-Tests/MFTRoutineTest.class.st
@@ -88,6 +88,6 @@
88
88
89
89
routine workouts: workouts.
90
90
91
Removed:
self assert: routine workouts class equals: Array.
92
Removed:
self assert: routine workouts equals: #( day1 day2 )
91
Added:
self assert: routine workouts class equals: OrderedCollection.
92
Added:
self assert: routine workouts equals: workouts
93
93
]
src/MyFitnessTracker-Core-Tests/MFTWorkoutPrescriptionTest.class.st
@@ -37,71 +37,6 @@
37
37
]
38
38
39
39
{ #category : 'tests' }
40
Removed:
MFTWorkoutPrescriptionTest >> testPrescribePreExhaustSupersetAddsPreExhaustGroup [
41
Removed:
42
Removed:
| workout firstSet secondSet group |
43
Removed:
workout := MFTWorkoutPrescription new.
44
Removed:
firstSet := self newSetPrescription.
45
Removed:
secondSet := self newSetPrescription.
46
Removed:
47
Removed:
workout prescribePreExhaustSuperset: {
48
Removed:
firstSet.
49
Removed:
secondSet }.
50
Removed:
group := workout setGroups first.
51
Removed:
52
Removed:
self assert: workout setGroups size equals: 1.
53
Removed:
self
54
Removed:
assert: group class
55
Removed:
equals: MFTPreExhaustSupersetGroupPrescription.
56
Removed:
self assert: group sets asArray equals: {
57
Removed:
firstSet.
58
Removed:
secondSet }.
59
Removed:
self assert: workout sets asArray equals: {
60
Removed:
firstSet.
61
Removed:
secondSet }
62
Removed:
]
63
Removed:
64
Removed:
{ #category : 'tests' }
65
Removed:
MFTWorkoutPrescriptionTest >> testPrescribeStraightSetAddsStraightSetGroup [
66
Removed:
67
Removed:
| workout set group |
68
Removed:
workout := MFTWorkoutPrescription new.
69
Removed:
set := self newSetPrescription.
70
Removed:
71
Removed:
workout prescribeStraightSet: set.
72
Removed:
group := workout setGroups first.
73
Removed:
74
Removed:
self assert: workout setGroups size equals: 1.
75
Removed:
self assert: group class equals: MFTStraightSetGroupPrescription.
76
Removed:
self assert: group sets size equals: 1.
77
Removed:
self assert: group sets first identicalTo: set.
78
Removed:
self assert: workout sets asArray equals: { set }
79
Removed:
]
80
Removed:
81
Removed:
{ #category : 'tests' }
82
Removed:
MFTWorkoutPrescriptionTest >> testPrescribeSupersetAddsSupersetGroup [
83
Removed:
84
Removed:
| workout firstSet secondSet group |
85
Removed:
workout := MFTWorkoutPrescription new.
86
Removed:
firstSet := self newSetPrescription.
87
Removed:
secondSet := self newSetPrescription.
88
Removed:
89
Removed:
workout prescribeSuperset: {
90
Removed:
firstSet.
91
Removed:
secondSet }.
92
Removed:
group := workout setGroups first.
93
Removed:
94
Removed:
self assert: workout setGroups size equals: 1.
95
Removed:
self assert: group class equals: MFTSupersetGroupPrescription.
96
Removed:
self assert: group sets asArray equals: {
97
Removed:
firstSet.
98
Removed:
secondSet }.
99
Removed:
self assert: workout sets asArray equals: {
100
Removed:
firstSet.
101
Removed:
secondSet }
102
Removed:
]
103
Removed:
104
Removed:
{ #category : 'tests' }
105
40
MFTWorkoutPrescriptionTest >> testSetGroupsCanBeReplaced [
106
41
107
42
| workout set group groups |
src/MyFitnessTracker-Core/MFTRoutine.class.st
@@ -6,7 +6,8 @@
6
6
#superclass : 'MFTObject',
7
7
#instVars : [
8
8
'title',
9
Removed:
'workouts'
9
Added:
'workouts',
10
Added:
'rest'
10
11
],
11
12
#category : 'MyFitnessTracker-Core-Prescription',
12
13
#package : 'MyFitnessTracker-Core',
@@ -25,20 +26,53 @@
25
26
yourself
26
27
]
27
28
29
Added:
{ #category : 'accessing' }
30
Added:
MFTRoutine >> addWorkout: aMFTWorkoutPrescription [
31
Added:
32
Added:
workouts addLast: aMFTWorkoutPrescription
33
Added:
]
34
Added:
28
35
{ #category : 'as yet unclassified' }
36
Added:
MFTRoutine >> averageSetsDuring: aDuration [
37
Added:
"Answer the average number of sets performed during a period of time."
38
Added:
39
Added:
self duration = Duration zero ifTrue: [ ^ 0 ].
40
Added:
^ (self sets size * (aDuration / self duration)) asFloat round: 1
41
Added:
]
42
Added:
43
Added:
{ #category : 'as yet unclassified' }
29
44
MFTRoutine >> canonicalName [
30
45
31
46
^ title
32
47
]
33
48
49
Added:
{ #category : 'as yet unclassified' }
50
Added:
MFTRoutine >> duration [
51
Added:
52
Added:
^ rest * workouts size
53
Added:
]
54
Added:
34
55
{ #category : 'initialization' }
35
56
MFTRoutine >> initialize [
36
57
37
58
super initialize.
38
Removed:
workouts := OrderedCollection new
59
Added:
workouts := OrderedCollection new.
60
Added:
rest := 2 days
39
61
]
40
62
63
Added:
{ #category : 'accessing' }
64
Added:
MFTRoutine >> removeWorkout: aMFTWorkoutPrescription [
65
Added:
66
Added:
workouts remove: aMFTWorkoutPrescription
67
Added:
]
68
Added:
41
69
{ #category : 'as yet unclassified' }
70
Added:
MFTRoutine >> sets [
71
Added:
72
Added:
^ workouts flatCollect: #sets
73
Added:
]
74
Added:
75
Added:
{ #category : 'as yet unclassified' }
42
76
MFTRoutine >> title [
43
77
44
78
^ title
@@ -55,7 +89,6 @@
55
89
56
90
| index |
57
91
workouts ifEmpty: [ ^ nil ].
58
Removed:
59
92
index := workouts
60
93
indexOf: aMFTWorkoutPrescription
61
94
ifAbsent: [ ^ workouts first ].
@@ -71,5 +104,5 @@
71
104
{ #category : 'accessing' }
72
105
MFTRoutine >> workouts: aMFTWorkoutPrescriptionCollection [
73
106
74
Removed:
workouts := aMFTWorkoutPrescriptionCollection asArray
107
Added:
workouts := aMFTWorkoutPrescriptionCollection asOrderedCollection
75
108
]
src/MyFitnessTracker-Core/MFTTrainee.class.st
@@ -5,8 +5,10 @@
5
5
#name : 'MFTTrainee',
6
6
#superclass : 'MFTObject',
7
7
#instVars : [
8
Removed:
'routine',
9
Removed:
'logBook'
8
Added:
'currentRoutine',
9
Added:
'routines',
10
Added:
'logBook',
11
Added:
'workoutPrescriptions'
10
12
],
11
13
#category : 'MyFitnessTracker-Core-Base',
12
14
#package : 'MyFitnessTracker-Core',
@@ -17,22 +19,48 @@
17
19
MFTTrainee class >> newDefault [
18
20
19
21
^ self new
20
Removed:
routine: MFTRoutine heavyDutyOneIdealRoutine;
22
Added:
currentRoutine: MFTRoutine heavyDutyOneIdealRoutine;
21
23
yourself
22
24
]
23
25
26
Added:
{ #category : 'accessing' }
27
Added:
MFTTrainee >> addRoutine: aMFTRoutine [
28
Added:
29
Added:
routines addLast: aMFTRoutine
30
Added:
]
31
Added:
32
Added:
{ #category : 'accessing' }
33
Added:
MFTTrainee >> addWorkoutPrescription: aMFTWorkoutPrescription [
34
Added:
35
Added:
workoutPrescriptions addLast: aMFTWorkoutPrescription
36
Added:
]
37
Added:
24
38
{ #category : 'initialization' }
25
39
MFTTrainee >> canonicalName [
26
40
27
41
^ 'trainee'
28
42
]
29
43
44
Added:
{ #category : 'accessing' }
45
Added:
MFTTrainee >> currentRoutine [
46
Added:
47
Added:
^ currentRoutine
48
Added:
]
49
Added:
50
Added:
{ #category : 'accessing' }
51
Added:
MFTTrainee >> currentRoutine: aMFTRoutine [
52
Added:
53
Added:
currentRoutine := aMFTRoutine
54
Added:
]
55
Added:
30
56
{ #category : 'initialization' }
31
57
MFTTrainee >> initialize [
32
58
33
59
super initialize.
34
Removed:
routine := MFTRoutine new.
35
Removed:
logBook := MFTWorkoutLogBook new
60
Added:
currentRoutine := MFTRoutine new.
61
Added:
logBook := MFTWorkoutLogBook new.
62
Added:
routines := OrderedCollection new.
63
Added:
workoutPrescriptions := OrderedCollection new
36
64
]
37
65
38
66
{ #category : 'testing' }
@@ -64,19 +92,32 @@
64
92
{ #category : 'testing' }
65
93
MFTTrainee >> nextWorkoutPrescription [
66
94
67
Removed:
routine workouts ifEmpty: [ ^ nil ].
68
Removed:
logBook workoutLogs ifEmpty: [ ^ routine workouts first ].
69
Removed:
^ routine workoutAfter: logBook workoutLogs last prescription
95
Added:
currentRoutine workouts ifEmpty: [ ^ nil ].
96
Added:
logBook workoutLogs ifEmpty: [ ^ currentRoutine workouts first ].
97
Added:
^ currentRoutine workoutAfter: logBook workoutLogs last prescription
70
98
]
71
99
72
100
{ #category : 'accessing' }
73
Removed:
MFTTrainee >> routine [
101
Added:
MFTTrainee >> routines [
74
102
75
Removed:
^ routine
103
Added:
^ routines
76
104
]
77
105
78
106
{ #category : 'accessing' }
79
Removed:
MFTTrainee >> routine: aMFTRoutine [
107
Added:
MFTTrainee >> routines: aMFTRoutineCollection [
80
108
81
Removed:
routine := aMFTRoutine
109
Added:
routines := aMFTRoutineCollection
110
Added:
]
111
Added:
112
Added:
{ #category : 'accessing' }
113
Added:
MFTTrainee >> workoutPrescriptions [
114
Added:
115
Added:
^ workoutPrescriptions
116
Added:
]
117
Added:
118
Added:
{ #category : 'accessing' }
119
Added:
MFTTrainee >> workoutPrescriptions: aMFTWorkoutPrescriptionCollection [
120
Added:
121
Added:
workoutPrescriptions := aMFTWorkoutPrescriptionCollection
122
Added:
asOrderedCollection
82
123
]
src/MyFitnessTracker-Core/MFTWorkoutLog.class.st
@@ -128,6 +128,12 @@
128
128
]
129
129
130
130
{ #category : 'accessing' }
131
Added:
MFTWorkoutLog >> removeSetGroup: aMFTSetGroupLog [
132
Added:
133
Added:
setGroups remove: aMFTSetGroupLog
134
Added:
]
135
Added:
136
Added:
{ #category : 'accessing' }
131
137
MFTWorkoutLog >> setForPrescription: aMFTSetPrescription [
132
138
133
139
^ self sets
src/MyFitnessTracker-Core/MFTWorkoutPrescription.class.st
@@ -86,6 +86,12 @@
86
86
MFTExercise closeGripPalmsUpPulldown))
87
87
]
88
88
89
Added:
{ #category : 'adding' }
90
Added:
MFTWorkoutPrescription >> addSetGroup: aMFTSetGroupPrescription [
91
Added:
92
Added:
setGroups addLast: aMFTSetGroupPrescription
93
Added:
]
94
Added:
89
95
{ #category : 'initialization' }
90
96
MFTWorkoutPrescription >> canonicalName [
91
97
@@ -102,9 +108,21 @@
102
108
{ #category : 'as yet unclassified' }
103
109
MFTWorkoutPrescription >> prescribe: aMFTSetGroupPrescription [
104
110
105
Removed:
setGroups addLast: aMFTSetGroupPrescription
111
Added:
self addSetGroup: aMFTSetGroupPrescription
106
112
]
107
113
114
Added:
{ #category : 'adding' }
115
Added:
MFTWorkoutPrescription >> removeSetGroup: aMFTSetGroupPrescription [
116
Added:
117
Added:
setGroups remove: aMFTSetGroupPrescription
118
Added:
]
119
Added:
120
Added:
{ #category : 'as yet unclassified' }
121
Added:
MFTWorkoutPrescription >> setCount [
122
Added:
123
Added:
^ self sets size
124
Added:
]
125
Added:
108
126
{ #category : 'initialization' }
109
127
MFTWorkoutPrescription >> setGroups [
110
128
@@ -114,7 +132,7 @@
114
132
{ #category : 'as yet unclassified' }
115
133
MFTWorkoutPrescription >> setGroups: aMFTSetGroupCollection [
116
134
117
Removed:
setGroups := aMFTSetGroupCollection
135
Added:
setGroups := aMFTSetGroupCollection asOrderedCollection
118
136
]
119
137
120
138
{ #category : 'as yet unclassified' }