
Mayur Lalwani
1,502 PointsHOW TO SOLVE IT??????
Totally stuck on this code challenge..NO idea what to do..
package com.example.model;
import java.util.HashSet;
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
mTags = new HashSet<String>();
}
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

Kourosh Raeen
23,710 PointsFor the first task you need to initialize mTags in the constructor. Use the new operator and an implementation of set like HashSet:
public Course(String title) {
mTitle = title;
// TODO: initialize the set mTags
mTags = new HashSet<>();
}
Also, don't forget to import HashSet.
Mayur Lalwani
1,502 PointsMayur Lalwani
1,502 PointsIt worked..thanks..
Mariette Grans
4,279 PointsMariette Grans
4,279 PointsAwesome. I tend to make it more difficult than it really is.