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 Data Structures - Retired Efficiency! Add tags to a course

Hey folks, I am stuck. I have to submit this to the employment agency by fri. Could someone send me the completed code?

I have made it almost all of the way but it has been long and difficult. I have to submit this in 2 days and I don't know how to get it right. in this case I would appreciate the actual finished code. Please help...Thanks

com/example/model/Course.java
package com.example.model;

import java.util.List;
import java.util.Set;

public class Course {
  private String mTitle;
  private Set<String> mTags;

  public Course(String title) {
    mTitle = title;
    // TODO: initialize the set mTags
  }

  public void addTag(String tag) {
    // TODO: add the tag
  }

  public void addTags(List<String> tags) {
    // TODO: add all the tags passed in
  }

  public boolean hasTag(String tag) {
    // TODO: Return whether or not the tag has been added
    return false;
  }

  public String getTitle() {
    return mTitle;
  }

}

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Jason!

mTags is a java.util.Set. It contains some methods that will help you solve this challenge add, addAll and contains.

Does that hint help?