View raw

1 " 2 I represent a named cycle of prescribed MFT activities. 3 " 4 Class { 5 #name : 'MFTRoutine', 6 #superclass : 'MFTObject', 7 #instVars : [ 8 'title', 9 'workouts', 10 'rest' 11 ], 12 #category : 'MyFitnessTracker-Core-Prescription', 13 #package : 'MyFitnessTracker-Core', 14 #tag : 'Prescription' 15 } 16 17 { #category : 'instance creation' } 18 MFTRoutine class >> heavyDutyOneIdealRoutine [ 19 20 ^ self new 21 title: 'Heavy Duty I — Ideal Routine'; 22 workouts: { 23 MFTWorkoutPrescription heavyDutyOneDay1. 24 MFTWorkoutPrescription heavyDutyOneDay2. 25 MFTWorkoutPrescription heavyDutyOneDay3 }; 26 yourself 27 ] 28 29 { #category : 'accessing' } 30 MFTRoutine >> addWorkout: aMFTWorkoutPrescription [ 31 32 workouts addLast: aMFTWorkoutPrescription 33 ] 34 35 { #category : 'as yet unclassified' } 36 MFTRoutine >> averageSetsDuring: aDuration [ 37 "Answer the average number of sets performed during a period of time." 38 39 self duration = Duration zero ifTrue: [ ^ 0 ]. 40 ^ (self sets size * (aDuration / self duration)) asFloat round: 1 41 ] 42 43 { #category : 'as yet unclassified' } 44 MFTRoutine >> canonicalName [ 45 46 ^ title 47 ] 48 49 { #category : 'as yet unclassified' } 50 MFTRoutine >> duration [ 51 52 ^ rest * workouts size 53 ] 54 55 { #category : 'initialization' } 56 MFTRoutine >> initialize [ 57 58 super initialize. 59 workouts := OrderedCollection new. 60 rest := 2 days 61 ] 62 63 { #category : 'accessing' } 64 MFTRoutine >> removeWorkout: aMFTWorkoutPrescription [ 65 66 workouts remove: aMFTWorkoutPrescription 67 ] 68 69 { #category : 'as yet unclassified' } 70 MFTRoutine >> sets [ 71 72 ^ workouts flatCollect: #sets 73 ] 74 75 { #category : 'as yet unclassified' } 76 MFTRoutine >> title [ 77 78 ^ title 79 ] 80 81 { #category : 'as yet unclassified' } 82 MFTRoutine >> title: aString [ 83 84 title := aString 85 ] 86 87 { #category : 'as yet unclassified' } 88 MFTRoutine >> workoutAfter: aMFTWorkoutPrescription [ 89 90 | index | 91 workouts ifEmpty: [ ^ nil ]. 92 index := workouts 93 indexOf: aMFTWorkoutPrescription 94 ifAbsent: [ ^ workouts first ]. 95 ^ workouts at: index % workouts size + 1 96 ] 97 98 { #category : 'accessing' } 99 MFTRoutine >> workouts [ 100 101 ^ workouts 102 ] 103 104 { #category : 'accessing' } 105 MFTRoutine >> workouts: aMFTWorkoutPrescriptionCollection [ 106 107 workouts := aMFTWorkoutPrescriptionCollection asOrderedCollection 108 ] 109