- #1
Robben
- 166
- 2
Homework Statement
If I have a subclass that implements a set class how can I avoid having to override all the set classes methods?
Homework Equations
None
The Attempt at a Solution
I have an interface:
Java:
import java.util.Set;
/**
* An extended Set where there is added functionality
*
* @version 3/23/14
*/
public interface NewSet<T> extends Set<T> {
/**
* Calculates the set union with the given input
*
* @param set - the set to perform the operation along with
* @return the set representing the invoked set and the parameter
*/
NewSet<T> union(NewSet<T> set);
//and a bunch more methods ...
}
And I have a class that extends this interface:
Java:
import java.util.ArrayList;
public class GSet<T> implements NewSet<T> {
// ...
}
Now, all my methods in NewSet has been implemented into GSet, but since NewSet extends Set<T> the compiler wants me to implement the methods of Set, i.e. addAll(), removeAll(), containsAll(), and more but I don't want to override those methods. Is there away to avoid this? Do I make my GSet abstract and thus make the methods that need to be implemented from set abstract as well? Or is there an easier way to go about doing this like backing up my GSet class with an arraylist?