1. Engineering
  2. Computer Science
  3. hello who can help with this program the program calls...

Question: hello who can help with this program the program calls...

Question details

hello who can help with this program,

the program calls Set and we have to make it with Interfaces .

========================================================================================================================

To spare you the hassle of implementing all of the methods of Java's very own Set interface, we have prepared our own interface for you to implement. Download our XYSet interface and place it in the package it longs to be in. Then, create a class ExcellentXYSet in the same package that implements the interface. How you save the data in your set is your decision, as long as you do not use Java's collections framework. You may, however, use classes you have already written over the course of the semester. If you do so, you can place them in the same source file as you already did in previous assignments.

You only have to submit ExcellentXYSet. The interface will be present on the test server.(the Server is to check if our code right or not ).

and her is our XYSet interfaces :

package programming.set11.xyset;

/**
* Classes that implement this interface represent a collection of values of
* which none may appear twice. Elements of an {@link XYSet} do not necessarily
* have a specific order. The methods this set supports are deviously inspired
* by the methods supported by Java's own {@link java.util.Set Set} interface.
*/
public interface XYSet<E> {

   /**
   * Adds an element to the set if it is not already part of the set.
   *
   * @param element
   * the element to be added.
   * @return {@code true} if the element was added to the set, {@code false} if
   * the element was already part of the set.
   * @throws NullPointerException
   * if {@code element} is {@code null}.
   */
   boolean add(E element);

   /**
   * Removes an element from the set if it is part of it.
   *
   * @param element
   * the element to be removed.
   * @return {@code true} if the element was in the set, {@code false} if it was
   * not.
   * @throws NullPointerException
   * if {@code element} is {@code null}.
   */
   boolean remove(E element);

   /**
   * Checks whether the given element is part of the set.
   *
   * @param element
   * the element to look for.
   * @return {@code true} if the element is part of the set.
   * @throws NullPointerException
   * if {@code element} is {@code null}.
   */
   boolean contains(E element);

   /**
   * Removes all elements from the set.
   */
   void clear();

   /**
   * Returns the number of elements in the set.
   *
   * @return the size of the set.
   */
   int size();

}

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution