" I represent a named cycle of prescribed MFT activities. " Class { #name : 'MFTRoutine', #superclass : 'MFTObject', #instVars : [ 'title', 'workouts', 'rest' ], #category : 'MyFitnessTracker-Core-Prescription', #package : 'MyFitnessTracker-Core', #tag : 'Prescription' } { #category : 'instance creation' } MFTRoutine class >> heavyDutyOneIdealRoutine [ ^ self new title: 'Heavy Duty I — Ideal Routine'; workouts: { MFTWorkoutPrescription heavyDutyOneDay1. MFTWorkoutPrescription heavyDutyOneDay2. MFTWorkoutPrescription heavyDutyOneDay3 }; yourself ] { #category : 'accessing' } MFTRoutine >> addWorkout: aMFTWorkoutPrescription [ workouts addLast: aMFTWorkoutPrescription ] { #category : 'as yet unclassified' } MFTRoutine >> averageSetsDuring: aDuration [ "Answer the average number of sets performed during a period of time." self duration = Duration zero ifTrue: [ ^ 0 ]. ^ (self sets size * (aDuration / self duration)) asFloat round: 1 ] { #category : 'as yet unclassified' } MFTRoutine >> canonicalName [ ^ title ] { #category : 'as yet unclassified' } MFTRoutine >> duration [ ^ rest * workouts size ] { #category : 'initialization' } MFTRoutine >> initialize [ super initialize. workouts := OrderedCollection new. rest := 2 days ] { #category : 'accessing' } MFTRoutine >> removeWorkout: aMFTWorkoutPrescription [ workouts remove: aMFTWorkoutPrescription ] { #category : 'as yet unclassified' } MFTRoutine >> sets [ ^ workouts flatCollect: #sets ] { #category : 'as yet unclassified' } MFTRoutine >> title [ ^ title ] { #category : 'as yet unclassified' } MFTRoutine >> title: aString [ title := aString ] { #category : 'as yet unclassified' } MFTRoutine >> workoutAfter: aMFTWorkoutPrescription [ | index | workouts ifEmpty: [ ^ nil ]. index := workouts indexOf: aMFTWorkoutPrescription ifAbsent: [ ^ workouts first ]. ^ workouts at: index % workouts size + 1 ] { #category : 'accessing' } MFTRoutine >> workouts [ ^ workouts ] { #category : 'accessing' } MFTRoutine >> workouts: aMFTWorkoutPrescriptionCollection [ workouts := aMFTWorkoutPrescriptionCollection asOrderedCollection ]