Commit 911dbd8e authored by Jakob Moser's avatar Jakob Moser
Browse files

Slightly re-structure exercise code

parent 8a9deecd
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -28,17 +28,18 @@ export class Exercise {
    constructor(name, index, execute) {
        this.name = name
        this.index = index
        // Bind the execute function to the ExerciseExecutionContext.
        // This means that the `this` keyword, when used in the function, will
        // point to this ExerciseExecutionContext object.
        this.#execute = execute.bind(this.#context)
        this.#execute = execute
    }
    
    /**
     * Start the exercise.
     */
    start() {
        this.#execute()
        // Bind the execute function to the ExerciseExecutionContext.
        // This means that the `this` keyword, when used in the function, will
        // point to this ExerciseExecutionContext object.
        // The newly bound function is then called.
        this.#execute.bind(this.#context)()
    }

    /**