Java Java Data Structures Efficiency! Add tags to a course

Stacy Chambers
Stacy Chambers
1,179 Points

I do not understand the task on this challenge

Can someone reword this challenge for me? Not sure what to do.

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

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

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

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

    mTags = new HashSet<String>();
  }

  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

Florian Tönjes
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 44,988 Points

Hi Stacy,

you already initialized the Set. The challenge now wants you to implement the addTag method. You have to add the tag, that is coming in to the method as a parameter, to the mTags set.

Kind Regards, Florian