Skip to content

Bug fixed - java programming 1 Part 06_13.exercise #22

Description

@derrykid

In ExerciseManagementTest.java,
you commented:

    @Test
    public void exerciseCanBeMarkedAsCompleted() {    
        management.add("New exercise");    
        management.markAsCompleted("New exercise");    
        assertTrue(management.isCompleted("New exercise"));
        //this test fails because of the add method not correctly addeding im assumeing the beleow test doesnn't work as intened as well.
        // ill try to fix it and understand it sometime later. I spent too long loocking into it right now
    }

The reason it doesn't work is because in Exercise class, the method

	public void setCompleted(boolean completed) {
		completed = completed;
	}

It has to code like this, where this.completed = completed;

	public void setCompleted(boolean completed) {

		this.completed = completed;
	}

It's because the parameter is named completed, so you have to use this.completed to specify your boolean value. Then the bug is fixed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions