Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A set is a collection of items without repetitions. The goal of this assign- ment is to implement a set as a data structure. Do

A set is a collection of items without repetitions. The goal of this assign- ment is to implement a set as a data structure. Do the following.

1. Starting with the template attached, implement a generic class SetT that maintains a set of items of generic type T using the class ArrayListT in the Java API. Your Set class must provide the following instance methods:

add: that adds a new item. (Ignore if already in the set.) remove: that removes an item. (Ignore if not in the set.)

membership: that returns true if a given item is in the set and false otherwise.

toString: that returns a string with the list of the items in the set.

2. Write a testSet class with a main() method that tests all the operations of the Set class above. That is, create an empty set A of integers, obtain from the user some integers and store some in A, display the set using toString(), obtain from the user some integers and remove them from A using remove(), display the set using toString(), obtain an integer from the user and check whether it is in A or not using membership() and display the result.

3*******. Expand your class SetT with the following static methods, and expand your testSet class to test them.

union: that returns the union of two given sets. intersection: that returns the intersection of two given sets.

difference: that returns the difference between two given sets.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The World Wide Web And Databases International Workshop Webdb 98 Valencia Spain March 27 28 1998 Selected Papers Lncs 1590

Authors: Paolo Atzeni ,Alberto Mendelzon ,Giansalvatore Mecca

1st Edition

3540658904, 978-3540658900

More Books

Students also viewed these Databases questions

Question

Express the number in decimal notation. 8.21 100 x 10

Answered: 1 week ago