View raw

1 " 2 I represent a user of MFT. 3 " 4 Class { 5 #name : 'MFTTrainee', 6 #superclass : 'MFTObject', 7 #instVars : [ 8 'currentRoutine', 9 'routines', 10 'logBook', 11 'workoutPrescriptions' 12 ], 13 #category : 'MyFitnessTracker-Core-Base', 14 #package : 'MyFitnessTracker-Core', 15 #tag : 'Base' 16 } 17 18 { #category : 'as yet unclassified' } 19 MFTTrainee class >> newDefault [ 20 21 ^ self new 22 currentRoutine: MFTRoutine heavyDutyOneIdealRoutine; 23 yourself 24 ] 25 26 { #category : 'accessing' } 27 MFTTrainee >> addRoutine: aMFTRoutine [ 28 29 routines addLast: aMFTRoutine 30 ] 31 32 { #category : 'accessing' } 33 MFTTrainee >> addWorkoutPrescription: aMFTWorkoutPrescription [ 34 35 workoutPrescriptions addLast: aMFTWorkoutPrescription 36 ] 37 38 { #category : 'initialization' } 39 MFTTrainee >> canonicalName [ 40 41 ^ 'trainee' 42 ] 43 44 { #category : 'accessing' } 45 MFTTrainee >> currentRoutine [ 46 47 ^ currentRoutine 48 ] 49 50 { #category : 'accessing' } 51 MFTTrainee >> currentRoutine: aMFTRoutine [ 52 53 currentRoutine := aMFTRoutine 54 ] 55 56 { #category : 'initialization' } 57 MFTTrainee >> initialize [ 58 59 super initialize. 60 currentRoutine := MFTRoutine new. 61 logBook := MFTWorkoutLogBook new. 62 routines := OrderedCollection new. 63 workoutPrescriptions := OrderedCollection new 64 ] 65 66 { #category : 'testing' } 67 MFTTrainee >> isRecovered [ 68 69 ^ logBook durationSinceLastWorkout 70 ifNotNil: [ :duration | duration > 2 days ] 71 ifNil: [ true ] 72 ] 73 74 { #category : 'accessing' } 75 MFTTrainee >> logBook [ 76 77 ^ logBook 78 ] 79 80 { #category : 'accessing' } 81 MFTTrainee >> logBook: aMFTWorkoutLogBook [ 82 83 logBook := aMFTWorkoutLogBook 84 ] 85 86 { #category : 'adding' } 87 MFTTrainee >> logWorkout: aMFTWorkoutLog [ 88 89 logBook logWorkout: aMFTWorkoutLog 90 ] 91 92 { #category : 'testing' } 93 MFTTrainee >> nextWorkoutPrescription [ 94 95 currentRoutine workouts ifEmpty: [ ^ nil ]. 96 logBook workoutLogs ifEmpty: [ ^ currentRoutine workouts first ]. 97 ^ currentRoutine workoutAfter: logBook workoutLogs last prescription 98 ] 99 100 { #category : 'accessing' } 101 MFTTrainee >> routines [ 102 103 ^ routines 104 ] 105 106 { #category : 'accessing' } 107 MFTTrainee >> routines: aMFTRoutineCollection [ 108 109 routines := aMFTRoutineCollection 110 ] 111 112 { #category : 'accessing' } 113 MFTTrainee >> workoutPrescriptions [ 114 115 ^ workoutPrescriptions 116 ] 117 118 { #category : 'accessing' } 119 MFTTrainee >> workoutPrescriptions: aMFTWorkoutPrescriptionCollection [ 120 121 workoutPrescriptions := aMFTWorkoutPrescriptionCollection 122 asOrderedCollection 123 ] 124