


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



import java.util.*;
public class PersonSet implements SetIntf {
TreeSet theSet;
// Constructors // ************************************** public PersonSet() { theSet = new TreeSet(); }
// ************************************** /**
if (!aPerson.isNull()) { result = theSet.add(aPerson); } else { result = false ; } } else { result = false ; } return result; }
if (anObject instanceof Person) { Person aPerson = (Person) anObject;
// Remove a particular element from set return theSet.remove(aPerson); } else { return false ; } }
return theSet.contains(aPerson); } else { return false ; } }
// ************************************** /**
// ************************************** /**
SetIntf.java
P. Grabow
P. Grabow
package
adapter1;
import
java.util.*;
public
interface
SetIntf {
boolean
insert(Object anObject);
boolean
remove(Object anObject);
boolean
isIn(Object anObject);
boolean
isEmpty();
void
clear();
int
size();
String toString();Iterator iterator();
SetIntf2.java
P. Grabow
P. Grabow
package adapter1;import java.util.*;public interface SetIntf2
boolean insert(T anObject);boolean remove(T anObject);boolean isIn(T anObject);boolean isEmpty();void clear();int size();String toString();Iterator