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 Java Objects Delivering the MVP Wrapping Up

I cant solve the 3rd task on the forum challenge :(

Hi, I'm struggling with the 3rd task on the forum challenge :( Can someone please explain how to link the user author in ForumPost.java to the user names in user?

public class ForumPost { private User author; private String title; private String description;

public post(author, String title, String description) {

author = User.getFirstName()+User.getLastName; title = post(title); description = post(description); }

Thank you in advance :D

1 Answer

Yanuar Prakoso
Yanuar Prakoso
15,196 Points

Hi There....

The answer is you do not have to. That matter of connecting User author to the firstName and lastName will be taken care of in the Main.java class in the 4th task when you finally uncomment a lot of commented codes. You just need to assign each of them (assuming you already pass first and second task seamlessly) it in the constructor of the class like so:

public class ForumPost {
  private User author;
  private String title;
  private String description;

  // TODO: add a constructor that accepts the author, title and description
  public ForumPost(User author, String title, String description) {
    this.author = author;
    this.title = title;
    this.description = description;
  }

  public User getAuthor() {
    return author;
  }

  public String getTitle() {
    return title;
  }

  public String getDescription() {
    return description;
  }
}

I hope this can help a little.