Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
derrykid opened this issue Dec 15, 2021 · 0 comments
Open

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

derrykid opened this issue Dec 15, 2021 · 0 comments

Comments

@derrykid
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant