Homework 10


Assigned Monday, April 13, 1998
Due Monday, April 20, 1998 at midnight
30 points


Re-implement the CircularList class using a circular linked list instead of an array. Note: there is an example of a linked list on page 180 in Chapter 6 of the blue book. Use the Elem class for each node.

Use the following template for this new CircularList implementation: CircularLinkedList
On top of this, create a Set class (similar but not identical to midterm 2, problem 4), filling out the appropriate method signatures.

Develop a class hw10 that implements a menu driven system for Set operations. This system should first prompt the user for the contents of two Sets, A and B. The user should enter positive integers (greater than or equal to zero) for the contents of the Sets. Entering a -1 should be the user's signal to the system that they are done entering the contents of a particular set. Once the Set contents are entered, the user is presented with a menu offering available Set operations and a quit option. This menu loops until the user selects quit.
>javac hw10
Enter an element of Set A: 1
Enter an element of Set A: 2
Enter an element of Set A: 3
Enter an element of Set A: -1
Enter an element of Set B: 3
Enter an element of Set B: 4
Enter an element of Set B: 5
Enter an element of Set B: -1

Menu for Sets

1 - Is_element of Set A
2 - Is_element of Set B
3 - Union
4 - Intersection
5 - Difference
6 - Symmetric difference
7 - Quit

1
What element? 2
2 is a member of Set A 

Menu for Sets

1 - Is_element of Set A
2 - Is_element of Set B 
3 - Union
4 - Intersection
5 - Difference
6 - Symmetric difference
7 - Quit

3
The Union of A and B is: 1 2 3 4 5

Menu for Sets

1 - Is_element of Set A
2 - Is_element of Set B
3 - Union
4 - Intersection
5 - Difference
6 - Symmetric difference
7 - Quit

5
The Difference of Sets A and B is: 1 2

Menu for Sets

1 - Is_element of Set A
2 - Is_element of Set B
3 - Union
4 - Intersection
5 - Difference
6 - Symmetric difference
7 - Quit

6
The Symmetric Difference of A and B is: 1 2 4 5

Menu for Sets

1 - Is_element of Set A
2 - Is_element of Set B
3 - Union
4 - Intersection
5 - Difference
6 - Symmetric difference
7 - Quit

7
Too bad this is the last homework...Bye...

Submit all your classes in one file called hw10.java (this should include the Elem, CircularLinkedList, Set, and hw10 classes). Submit this file and a README file in a directory called hw10.