My assignment is as follow:

Create a class IntegerSet. The IntegerSet can hold integers in the range [1-100]. Define one or more instance variables to represent IntegerSet properties and store elements. Additionally, provide the following methods:
a. One or more constructors.
b. Method void add(int) inserts a new element to the set.
c. Method void delete(int) deletes the element from the set.
d. Method IntegerSet union(IntegerSet) creates/returns a third set that is the union of two sets.
e. Method IntegerSet intersection(IntegerSet) creates a third set that is the intersection of two sets.
f. Method int cardinality() returns the number of elements in the set.
g. Method boolean isEqualTo(IntegerSet) determines if two sets are equal.
h. Method toString() returns a string description of all elements of the set.
i. Method boolean isEmpty() returns true if the set is empty.
j. Method boolean isSubset(IntegerSet) determines if the set is a subset of the parameter IntegerSet.
k. Method boolean isPrimeSet() returns true if all elements of the set are prime numbers.
Create a test program (named that can demonstrate IntegerSet class and its methods.
An example of
IntegerSet s1 = new IntegerSet();
IntegerSet s2 = new IntegerSet();
s1.add(150); // your program should properly act for this case (i.e. display “wrong input” msg.)
s1.add(0); // your program should properly act for this case (i.e. display “wrong input” msg.)
System.out.println(s1.cardinality()); // should display 2
System.out.println(s1.toString()); // should display {5, 95} or {95, 5}
System.out.println(s2); // should display {6, 99} or {99, 6}
IntegerSet s3 = s1.union(s2);
System.out.println(s3); // should display {5, 6, 95, 99} or elements in a different order
s3.delete(7); // your program should properly act for this case (i.e. display “cannot delete” msg.)
System.out.println(s3); // should display{6, 95, 99} or elements in a different order
IntegerSet s4 = s3.intersection(s1);
System.out.println(s4); // should display {95}
System.out.println(s1.isEqualTo(s4)); // should display false
System.out.println(s1.isSubset(s4)); // should display false
System.out.println(s4.isSubset(s1)); // should display true
System.out.println(s1.isPrimeSet()); // should display true
System.out.println(s1.isEmpty()); // should display true

I'm really having trouble trying to solve this, I'm not very good a Java but want to learn it. I'm not asking you to do it all ( though that would be awesome :] ) but it will help me follow through, as sort of a guideline. Please help

The instructions almost write it for you...
ALL you need to do is translate them into Java code. If you can't do even that you should go back to the very first lesson you got and restart from there.

This article has been dead for over six months. Start a new discussion instead.