A paper copy of your program should be turned in at the beginning of
class.
Your work should be dropped off electronically in the Lamont folders by
10:00 AM on the due date.
Late Deadline: turn in by Midnight Friday April 4 for a 10% penalty.
(Paper on my office door.)
For further details on how to hand in assignments, see these Submission
Guidelines.
Create a Set class that keeps its elements (strings) in a linked list.
Your Set class should support all
the operations used in the code below. (Paste the code given
below into your main to test your class.)
Create additional Set methods and classes if needed. All data members
should be private and the
only allowed friend classes are a list and its node. Recall that
the order of the elements in a set is not
important, but no element should appear more than once. Also
two sets are equivalent if each is a
subset of the other.
Set prez;
Set vp;
prez.insert("LBJ");
if (prez.includes("LBJ"))
vp.display(); // the order of the elements doesn't matter
Set uni = prez.union(vp);
Set inter = prez.intersect(vp);
Set bushes;
if (bushes.subsetOf(prez))
Set uni2 = vp.union(prez);
if (uni.equivalentTo(uni2))
prez.insert("Bush
Jr.");
prez.insert("Clinton");
prez.insert("Bush
Sr.");
cout << "LBJ was a prez." << endl;
else
cout << "LBJ was not a prez." << endl;
vp.insert("Bush
Sr.");
vp.insert("Gore");
vp.insert("Cheney");
vp.insert("LBJ");
vp.insert("Gore"); // trick! this should not result in
2 Gore's
uni.display(); // should see all the people,
no repetitions
inter.display(); // should see only the intersection
bushes.insert("Bush Jr.");
bushes.insert("Bush Sr.");
cout << "bushes is a subset" << endl;
else
cout << "bushes is not a subset" <<
endl;
cout << "two unions are the same" <<
endl;
else
cout << "two unions are not the same" <<
endl;