



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Grabow; Class: Software Engineering I; Subject: Computer Science; University: Baylor University; Term: Spring 2009;
Typology: Study notes
1 / 6
This page cannot be seen from the preview
Don't miss anything!




package adapterprj; import java.util.*;
public interface SetInterface {
public boolean insert( Object anObject ); public boolean remove( Object anObject ); public boolean isIn(Object anObject); public boolean isEmpty(); public void clear(); public int count(); public String toString(); public Iterator iterator(); }
package adapterprj;
import java.util.*;
public class PersonSet implements SetInterface {
TreeSet theSet;
// ************************************** /**
*/ public PersonSet() { theSet = new TreeSet(); }
if (!aPerson.isNull()) { return theSet.add(aPerson); } else { return false; } } else { return false; }
// Remove a particular element from set return theSet.remove(aPerson); } else { return false; } }
// ************************************** /**
return theSet.contains(aPerson); } else { return false; } }
// ************************************** /**
// ************************************** /**
*/ public void clear() { // Remove all elements of set theSet.clear(); }
String tempLast = Common.normalize(aLastname); if (Common.isValidName(tempFirst) && Common.isValidName(tempLast)) { m_firstname = tempFirst; m_lastname = tempLast; } else { m_firstname = Common.NULL_STRING; m_lastname = Common.NULL_STRING; } }
// Extractors // *************************************************** /**
/**
// Relational operators // *************************************************** /**
/**
public boolean isLess(Person aPerson) { return (compareTo(aPerson) < 0); }
less than: negative integer; * equal: zero; * greater than: positive integer<\P> * @param anObject * @return int */ public int compareTo(Object anObject) { Person aPerson = (Person) anObject; int lastCmp = m_lastname.compareToIgnoreCase(aPerson.m_lastname);
if (lastCmp == 0) { return m_firstname.compareToIgnoreCase(aPerson.m_firstname); } else { return lastCmp; } } }
package adapterprj;
public class Common {
// Operations and data that are common to all of the other classes