CpSc 210, Section 1
Assignment 4
June 12, 2000
Due: Wednesday, June 20 by 11:59 p.m.
Assignment: Implementing set operations using lists.
Total point value of assignment: 100 points
Not accepted late.
This assignment is to be done INDIVIDUALLY.
Create a file, Set.java, which will contain assignment. Set.java will contain
the methods listed below and the
additional methods toString() and equals.
A set is a collection without order and without duplicates and may be empty.
We will use a linked list to implement a set of Objects. The specification of the Set is as follows.
public Set ( )
// constructs an empty set
public void insert ( Object newItem )
// post: If newItem is already in Set, no action is taken
// otherwisse, newItem is inserted into Set
public boolean contains ( Object item )
// post: Returns true if Item is in set. Otherwise, returns false.
public boolean remove ( Object item )
// post: Returns false if item is not in set.
// Otherwise, removes item from set and returns true.
public String toString ( )
// post: Returns a String representation of this Set
public Set intersection ( Set other )
// post: Returns the intersection of this Set and other Set
public Set union ( Set other )
// post: Returns the union of this Set and other Set
public boolean equals ( Object other )
// post: Returns true if this and other contain exactly the
// same items (but not necessarily stored in the same order).
// Otherwise, returns false.
Your main method should contain a test program which tests all methods. In addition, at some point in the test program, all code should have been tested.
Set.java may contain any additional methods that would be helpful. For example, you might write a method to print out "CPSC 210", your name, the assignment number, and a brief description of the assignment.
Other requirements:
The first operation of your main program must be to print "CPSC 210", your name, the assignment number, and a brief description of the assignment.
Follow the style standards to be found on your instructor's
web page for CPSC 210.
Submit your program using the handin command. There is a link to
the handin description on the CPSC 210 lab page (www.cs.clemson.edu/~lab210).
Grading rubric:
In the opinion of the instructor the program is an honest attempt
to complete the assignment as described 5 pt.
The program compiles without error. 10 pts.
If the two previous requirements are not substantially met, no further
points will be awarded.
Correctness, documentation, style, and quality of test program. 85 pts.
Points will be subtracted for failure to follow style standards.
The methods will be tested in the order in which they are listed
above. If at any point your Set causes the test program to fail,
no further testing will be done and your grade will be determined
by the test results at that point.