- #1
Robben
- 166
- 2
Homework Statement
How do I take the union between an object called on and the object passed in the parameter?
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, the union method requires a NewSet object to be called on. The Union will be performed between the object called on and the object passed in the parameter, which is set. But I am confused on how to do this?
How do I call on a NewSet object in order to take the union between the object called on and the object passed in?
Do I just do:
Java:
public NewSet<T> union(NewSet<T> set) {
NewSet<T> calledOn = new ArrayList<T>();
// ...
}
Or is that totally wrong and I am not understanding what it means for an object to be called on?