mooc-java-programming-i icon indicating copy to clipboard operation
mooc-java-programming-i copied to clipboard

Bug fixed - java programming 1 Part 06_13.exercise

Open derrykid opened this issue 4 years ago • 0 comments

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.

derrykid avatar Dec 15 '21 10:12 derrykid