Assignment 5 Solution

$30.00

Description

Assignment 5 Skills

Linked Data

Assignment 5 Background

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

Assignment 5 Requirements

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

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

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

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

    1. isEmpty, that determines the emptyness of the set.

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

    1. clear, that removes all elements from the set.

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

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

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

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

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

    1. the expected behavior of each method.

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

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

    1. anything else of importance in your design choices.

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

    1. an private Object reference for the stored data.

    1. a private Node reference for the next link.

    1. Constructors/getters/setters as necessary.

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

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

    1. implementations for all of the interface methods.

    1. a toString method for displaying the contents of the set.

  1. (10%) Provide comments for the class as necessary being sure to document:

    1. how you add elements to the chain.

    1. how you remove elements from the chain.

    1. anything else of importance in your implementation choices.

  1. (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:

  1. SetInterface.java

  1. Node.java

  1. LinkedSet.java

  1. 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.