Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Spring Basics Using the MVC Architecture Fix a Model

Jennifer Kron
Jennifer Kron
10,669 Points

Missing a getter?

I'm having trouble figuring out what else I need to change/add for this challenge. My original thinking was that it was missing a getter to be able to access the private Complete field.

com/teamtreehouse/todo/model/Task.java
package com.teamtreehouse.todo.model;

import java.time.LocalDateTime;

public class Task {
  private String description;
  private LocalDateTime dueDateTime;
  private boolean complete;

  public Task(String description, LocalDateTime dueDateTime) {
    this.description = description;
    this.dueDateTime = dueDateTime;
    this.complete = false;
  }

  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;  
  }

  public LocalDateTime getDueDateTime() {
    return dueDateTime;  
  }

  public void setDueDateTime(LocalDateTime dueDateTime) {
    this.dueDateTime = dueDateTime;  
  }

  public void setComplete(boolean complete) {
    this.complete = complete;  
  }

   public void getComplete() {
    return complete;  
  }


}

1 Answer

Florian Tönjes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 Points

Hi Jennifer,

you want the getter to return a boolean, but you made the method void. I also prefer to prefix boolean getters with "is" like "isComplete()", I think that looks better.

Kind Regards, Florian