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 trialJohn Paige
7,436 PointsTask 3 of 4 on Wrapping Up Challenge: How do I set User author as one of the parameters?
Hello, everyone. I hope whoever is reading made it thru the course with flying colors.
I seem to be stuck on this task. Here is my code:
public class ForumPost {
private User mAuthor;
//I defined the mTitle and mDescription strings
private String mTitle, mDescription;
//Then here is my attempt at crating a constructor to take the User author, String title, and String description parameters
public void ForumPost(User author, String title, String description) {
author = mAuthor;
mTitle = title;
mDescription = description;
}
//my description getter, which I think is just fine
public String getDescription() {
return mDescription;
}
public User getAuthor() {
return mAuthor;
}
public String getTitle() {
return mTitle;
}
// TODO: We need to expose the description
}
I could be missing more than I think I am, but I think my issue is I don't know how to get my constructor to take the User author parameter. When I run my code, I get the message
"Bummer! Please add the constructor with the following parameters: User author, String title, String description."
I'd appreciate the insight, and it doesn't matter to me if it's a direct answer to pass the challenge or if it is a hint.
1 Answer
Liam Cassidy
9,739 Pointsremove the 'void' in your constructor:
should be:
public ForumPost(User author, String title, String description) {
author = mAuthor;
mTitle = title;
mDescription = description;
}
John Paige
7,436 PointsJohn Paige
7,436 PointsThank you, Liam Cassidy. I came back to the challenge and edited 'void' out of my ForumTopic constructor and it passed. Here is my passing code as follows:
I will post on this thread again if I have just as much trouble on task 4. As of writing...I will go ahead and get on it.
Thanks again. I welcome more insights from other who have passed. I'll vote you up, lol.