/    Sign up×
Community /Pin to ProfileBookmark

Help with Java

This is alot of Information but please help me I am completely lost.

I need to write a ADT set in Java with some specifications.
First I need to produce a more formal specification of the ADT set including the following:
a.Syntax specifications of the set operations expressed as Ada-like routine headings with in, out, and inout mode parameters as appropriate. The required routines are the functions create, insert, delete, union, intersection, and difference. Additionally, you will implement the functions empty and member.

b.Specifications of the semantics of the routines as pre-conditions and post-conditions in simple English.

Then I need tosetup a set. A set is defined as an unordered collection of distinct (unique) values

A significant difference between a set and other structured data types, such as records and lists, is that the elements of a set are unordered. Accessing the elements of a set by indexing or by relative position plays no part in set processing.

A second important characteristic of a set is that it contains no duplicate values. All of its elements have distinct values.

Another interesting feature is that the set may be empty. That is, the set may have no elements.

A set is most easily specified in terms of the operators associated with it. The basic set operations are as follows:
• Set creation: create a new set S, which is initially empty
• Membership test: is data value X a member of set S?
• Insertion: if data value X is not a member of set S, then insert X into S
• Deletion: if data value X is a member of set S, then remove X from S
• Union: given two sets S1 and S2, create a set S3 containing all members of both S1 and S2. S1 and S2 remain unchanged.
• Intersection: given two sets S1 and S2, create a set S3 containing all members of S1 that are also members of S2. S1 and S2 remain unchanged.
• Difference: given two sets S1 and S2, create a set S3 containing all members of S1 that are not in S2. S1 and S2 remain unchanged.
• Empty: if the set S has no members, then Empty is true, otherwise it is false. S remains unchanged.

A set is normally denoted by enclosing its associated members in square brackets as follows:

[‘A’,’E’,’I’,’O’,’U’] – denotes a set of vowels A, E, I, O, U
[‘A’..’Z’] – denotes the set of all upper case letters A to Z.
[ ] – denotes the empty set

Note that [‘a’,’e’,’i’,’o’,’u’] = [‘e’,’a’,’u’,’o’,’i’] is true since set elements are not ordered.

The requirements are1. The student will write the ADT “set” as a “header” file describing the set and an “implementation” file, which implements the set functions. If using a language like Java, the header and implementation will be in the same .java file which implements the Set class.
2. The student will then write another “main” program, which uses the ADT set. The main program will perform the following:
a. Instantiate/create five new sets with the identifiers a, b, c, d, and e
b. Insert members 0 through 9 into set a
c. Insert members 5 through 14 into set b
d. Display sets a and b.
e. Perform the Union of sets a and b and place the results in set c.
f. Display set c.
g. Perform the Intersection of sets a and b and place the results in set d.
h. Display set d.
i. Perform the Difference of sets a and b and place the results in set e.
j. Display set e.
k. Delete the number 10 from set a (remember, 10 is NOT a member of set a)
l. Display set a.
m. Delete the number 9 from set a.
n. Display set a.
o. Insert the number 16 into set b.
p. Display set b.
q. Delete the number 1 from set c.
r. Display set c.
s. Insert the number 1 back into set c.
t. Display set c.
3. For each output in the above instructions where the program displays a set, the program must denote which set is being displayed (i.e. Set A = …)
4. Outputs are to be written to either the screen or to a GUI such as a message box or a window.
5. The program is only required to do one run at a time (i.e. the program does not need to run until a user decides to quit).

6. The program must maintain a log of all set functions (create, insert, delete, member, empty, intersection, union, difference).

to post a comment
Java

0Be the first to comment 😎

×

Success!

Help @NickCole spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...