This is one of three major individual assignments that you are required to complete in this class. You MUST design and code this project on your own. You can ask for debugging help, particularly from the tutors, TA or instructor, but this project is to be your own work. The project relies on knowledge and skills that you will develop in Recitation Laboratories 1-3. If you are having trouble with these recitations after your in-class session, please be sure that you come to the lab at another time and sit down with a tutor.
A set can contain any type of data. You will implement a set
that contains pairs of data as elements of the set. For example
if a set contains pairs of Integers the following set might be
constructed. {{1,2},{4,8},{4,10},{9,12}}. Similarly if the
set contains pairs of Characters the following set might be contructed
{{A,B},{C,G},{C,I}).
The following Java interface defines a set of
simple operations of pairSet. Notice the differences between the
pairSetADT and SetADT, which was discussed in the classes.
import java.util.Iterator;In this project your task is to design a class ArrayOrderedPairset that implements the pairSetADT interface. The ArrayOrderedPairset will use an array to store the data and keep elements of a pairset in ascending order. You may design additional classes if necessary. You will also develop a test class called ArrayOrderedPairsetTester to determine if the ArrayOrderedPairset class works properly. These classes should be placed in a pairsetpkg package. Your project should also be called pairset. The package you will be developing is similar to the sets package that contains the ArraySet class developed during the lecture. The full code for ArraySet is available in Chapter 3 of the textbook, in the jss2.jar file, and in week 3 lecture project.
public interface pairSetADT<T extends Comparable> {
// Adds one element to this multiset
public void add(T element1, T element2);
// Adds all elements of the given pairset to this pairset
public void addAll(pairSetADT<T> s);
// Removes from this pairset and returns true / false for success
public boolean removeRandom();
// Removes one occurence of the give element from this pairset
// and returns success
public boolean remove(T element1, T element2);
// Removes all occurences of the given element from this pairset
// and returns the number of elements removed
public int removeAll(T element);
// Returns the union of the two pairset
// Example: {a, a; b, c} union {a, b; b, c} = {a, a; a, b; b, c}
public pairSetADT<T> union(pairSetADT<T> s);
// Returns the intersection of this and the given multisets
// Example: {a, a; b, c} intersection {a, b; b, c} = {b, c}
public pairSetADT<T> intersection(pairSetADT<T> s);
// returns true if the pairset contains the target element
public boolean contains(T target1, T target2);
// Returns true if this and the given pairset contain exactly
// the same set of elements .
public boolean equals(pairSetADT<T> s);
// Returns true if this pairset contains no elements
public boolean isEmpty();
// Returns the number of elements in this pairset
public int size();
// Returns an iterator for the first element in each of the pairs in the pairset
public Iterator<T> iteratorFirst();
// Returns an iterator for the second element in each of the pairs in the pairset
public Iterator<T> iteratorSecond();
// Returns a string representation of this pairset
public String toString();
}
You may have noticed by now that we have not included specifications for the testing of your classes. You are responsible of developing code that fully tests your program. You will be submitting your complete package as a single zip file. We will be running your project with our own client code to determine the correctness of your work. It is therefore important to test all different uses of the ArrayOrderedPairset class.