Starting from:
$30

$24

Assignment 5 Solution

Assignment 5 Skills




Linked Data




Assignment 5 Background




For this assignment we will be building o of Assignment 4.




Assignment 5 Requirements




(10%) Update your SetInterface if needed. This interface should have the following methods de ned:



Add, that adds an element to the set if able.



Remove (random), that removes a (random) element from the set. This does not have to be truly random.



Remove (speci ed), that removes a speci ed element from the set if able.



isEmpty, that determines the emptyness of the set.



getCurrentSize, that returns the number of elements currently in the set.



clear, that removes all elements from the set.



contains, that determines whether a speci ed element is in the set.



union, that returns a set with all of the elements of this set, and the speci ed set.



intersection, that returns a set with all of the common elements in this set, and the speci ed set.



di erence, that returns a set with all of the elements in this set, that are not in the speci ed set.



(10%) Provide comments for the interface as necessary being sure to document:



the expected behavior of each method.



the return types, and expected return values (if any).



the conditions for success/failure, and expected handling of such (if any).



anything else of importance in your design choices.



(20%) Write a class called Node. This class should include the following:



an private Object reference for the stored data.



a private Node reference for the next link.



Constructors/getters/setters as necessary.



(30%) Write a class called LinkedSet that implements the SetInterface interface. This class should include the following:



a private head Node to hold the chain of set elements.



implementations for all of the interface methods.



a toString method for displaying the contents of the set.
(10%) Provide comments for the class as necessary being sure to document:



how you add elements to the chain.



how you remove elements from the chain.



anything else of importance in your implementation choices.



(20%) Write a main method in a le called SetTest.java. Your main method should test your implementation thoroughly. Be sure to document what you are testing at each point.









Assignment 5 Submission Submit on Blackboard:




SetInterface.java



Node.java



LinkedSet.java



SetTest.java



Required Each submitted le should include your name and a statement that this is your own work. This should appear as a comment at the beginning of any code le.

More products