Additional in Structured Gym Regimen

Hello,
I’m stucked with an additional challenge " * Add a mutating method to the Regimen structure to add exercises."

Look at my code, please:

struct Exercise {
var name: String
var muscleGroups: [String]
var reps: Int
var sets: Int
var totalReps: Int

init (name: String, muscleGroups: [String], reps: Int, sets: Int) {
self.name = name
self.muscleGroups = muscleGroups
self.reps = reps
self.sets = sets
self.totalReps = reps * sets
}
}

var pushUp = Exercise(name: “Push up”, muscleGroups: [“Triceps”, “Chest”, “Shoulders”], reps: 10, sets: 3)

var hover = Exercise(name: “Hover”, muscleGroups: [“Press”, “Triceps”], reps: 5, sets: 2)

struct Regimen {
var dayOfWeek: String
var exercises: [Exercise]
init(dayOfWeek: String, exercises: [Exercise]) {
self.dayOfWeek = dayOfWeek
self.exercises = exercises
}

func printExercisePlan() {
print(“Today is (self.dayOfWeek) and the plan is to:”)
for exercise in self.exercises {
print(“Do (exercise.sets) sets of (exercise.reps) (exercise.name)s”)
print(“That’s a total of (exercise.totalReps) (exercise.name)s”)
}
}

mutating func addHover() {
print(“Let’s try more today”)
self.exercises = exercises.append(hover)
}
}

var mondayRegimen = Regimen (dayOfWeek: “Monday”, exercises: [pushUp])
mondayRegimen.printExercisePlan()

var tuesdayRegimen = mondayRegimen.addHover()
tuesdayRegimen.printExercisePlan()

I’ve added the second exercise (var hover) and tried to use mutating method and make program add this exercise to tuesdayRegimen. But somehow it is not working. How can I make it correctly?

Aw, I’ve realised my mistake with some help. I’ve tried to make tuesdayRegimen from mondayRegimen by using mutating method. But it’s not correct. And I should use mutating method for changing already created Regimen.

So, now I use mutating method for adding hover exercise to mondayRegimen, while tuesdayRegiment create as instances. and it works.

My code below, if it is intersting for someone as an example:

struct Exercise {
var name: String
var muscleGroups: [String]
var reps: Int
var sets: Int
var totalReps: Int

init (name: String, muscleGroups: [String], reps: Int, sets: Int) {
self.name = name
self.muscleGroups = muscleGroups
self.reps = reps
self.sets = sets
self.totalReps = reps * sets
}
}

var pushUp = Exercise(name: “Push up”, muscleGroups: [“Triceps”, “Chest”, “Shoulders”], reps: 10, sets: 3)

var hover = Exercise(name: “Hover”, muscleGroups: [“Press”, “Triceps”], reps: 5, sets: 2)

struct Regimen {
var dayOfWeek: String
var exercises: [Exercise]

init(dayOfWeek: String, exercises: [Exercise]) {
self.dayOfWeek = dayOfWeek
self.exercises = exercises
}
func printExercisePlan() {
print(“Today is (self.dayOfWeek) and the plan is to:”)
for exercise in self.exercises {
print(“Do (exercise.sets) sets of (exercise.reps) (exercise.name)s”)
print(“That’s a total of (exercise.totalReps) (exercise.name)s”)
}
}

mutating func addHover() {
print(“Let’s try more today”)
self.exercises.append(hover)
}
}

var mondayRegimen = Regimen (dayOfWeek: “Monday”, exercises: [pushUp])
var tuesdayRegimen = Regimen(dayOfWeek: “Tuesday”, exercises: [pushUp])

mondayRegimen.addHover()
mondayRegimen.printExercisePlan()
tuesdayRegimen.printExercisePlan()

And then I tried to go further and make my mutating method more general so it would be able to add not only “hover exercise” but different exercises.
And I whote the final version:

struct Exercise {
var name: String
var muscleGroups: [String]
var reps: Int
var sets: Int
var totalReps: Int

init (name: String, muscleGroups: [String], reps: Int, sets: Int) {
self.name = name
self.muscleGroups = muscleGroups
self.reps = reps
self.sets = sets
self.totalReps = reps * sets
}
}

var pushUp = Exercise(name: “Push up”, muscleGroups: [“Triceps”, “Chest”, “Shoulders”], reps: 10, sets: 3)

var hover = Exercise(name: “Hover”, muscleGroups: [“Press”, “Triceps”], reps: 5, sets: 2)

var squat = Exercise(name: “Squat”, muscleGroups: [“Hip”, “Gluteus”], reps: 10, sets: 3)

struct Regimen {
var dayOfWeek: String
var exercises: [Exercise]

init(dayOfWeek: String, exercises: [Exercise]) {
self.dayOfWeek = dayOfWeek
self.exercises = exercises
}

func printExercisePlan() {
print(“Today is (self.dayOfWeek) and the plan is to:”)
for exercise in self.exercises {
print(“Do (exercise.sets) sets of (exercise.reps) (exercise.name)s”)
print(“That’s a total of (exercise.totalReps) (exercise.name)s”)
}
}

mutating func addExercise(newExercise: Exercise) {
self.exercises.append(newExercise)
}
}

var mondayRegimen = Regimen (dayOfWeek: “Monday”, exercises: [pushUp]
var tuesdayRegimen = Regimen(dayOfWeek: “Tuesday”, exercises: [pushUp])

mondayRegimen.addExercise(newExercise: squat)
mondayRegimen.printExercisePlan()

tuesdayRegimen.addExercise(newExercise: hover)
tuesdayRegimen.printExercisePlan()

P.S. sorry for my English, I’m not native