Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java In this lab, you will write an interface for a list that contains different

ID: 3890541 • Letter: J

Question

Java

In this lab, you will write an interface for a list that contains different methods than those contained in the ListInterface class from Chapter 12. With this kind of list, the user can only access the beginning or ending elements of a list, not any elements from the middle of the list. Specify this list in an interface called EntryWayListInterface<T>.

Note that you are only creating the interface; you are not implementing the methods.

Requirements-

Your interface must:

-compile

-contain these exact method headers:

boolean insertHead(T newEntry)

boolean insertTail(T newEntry)

T deleteHead() (returns the object that has been deleted)

T deleteTail() (returns the object that has been deleted)

void display()

int contains(T anEntry) (returns the position of the entry that was found)

boolean isEmpty()

boolean isFull()

-use appropriate javadoc-style comments (80 points)

You can review the ListInterface.java file or the resources listed here (Links to an external site.)Links to an external site. for examples of javadoc-style comments

Include comments about the purpose of the interface.

Each method should have a javadoc-style comment describing:

-what the method does

-what the parameters are (if any)

-what the method returns (if anything)

You should run a javadoc tool to test your comments.

------------------

ListInterface.java

/** An interface for the ADT list.

Entries in a list have positions that begin with 1.

*/

public interface ListInterface<T>

{

   /** Adds a new entry to the end of this list.

   Entries currently in the list are unaffected.

   The list's size is increased by 1.

   @param newEntry The object to be added as a new entry. */

   public void add(T newEntry);

   /** Adds a new entry at a specified position within this list.

   Entries originally at and above the specified position

   are at the next higher position within the list.

   The list's size is increased by 1.

   @param newPosition An integer that specifies the desired

   position of the new entry.

   @param newEntry The object to be added as a new entry.

   @throws IndexOutOfBoundsException if either

newPosition < 1 or newPosition > getLength() + 1. */

   public void add(int newPosition, T newEntry);

   /** Removes the entry at a given position from this list.

   Entries originally at positions higher than the given

   position are at the next lower position within the list,

   and the list's size is decreased by 1.

   @param givenPosition An integer that indicates the position of

   the entry to be removed.

   @return A reference to the removed entry.

   @throws IndexOutOfBoundsException if either

givenPosition < 1 or givenPosition > getLength(). */

   public T remove(int givenPosition);

   /** Removes all entries from this list. */

   public void clear();

   /** Replaces the entry at a given position in this list.

   @param givenPosition An integer that indicates the position of

   the entry to be replaced.

   @param newEntry The object that will replace the entry at the

position givenPosition.

   @return The original entry that was replaced.

   @throws IndexOutOfBoundsException if either

givenPosition < 1 or givenPosition > getLength(). */

   public T replace(int givenPosition, T newEntry);

   /** Retrieves the entry at a given position in this list.

   @param givenPosition An integer that indicates the position of

   the desired entry.

   @return A reference to the indicated entry.

   @throws IndexOutOfBoundsException if either

givenPosition < 1 or givenPosition > getLength(). */

   public T getEntry(int givenPosition);

   /** Retrieves all entries that are in this list in the order in which

   they occur in the list.

   @return A newly allocated array of all the entries in the list.

If the list is empty, the returned array is empty. */

   public T[] toArray();

   /** Sees whether this list contains a given entry.

   @param anEntry The object that is the desired entry.

   @return True if the list contains anEntry, or false if not. */

   public boolean contains(T anEntry);

   /** Gets the length of this list.

   @return The integer number of entries currently in the list. */

   public int getLength();

   /** Sees whether this list is empty.

   @return True if the list is empty, or false if not. */

   public boolean isEmpty();

} // end ListInterface

Explanation / Answer

/*********************EntryWayListInterface.java*****************************/

/**

* An interface for the ADT list. Entries in a list have positions that begin

* with 1.

*

* @param <T> the generic type

*/

public interface EntryWayListInterface<T> {

/**

* Insert head into List.

*

* @param newEntry the new entry

* @return true, if successful

*/

boolean insertHead(T newEntry);

/**

* Insert tail into List.

*

* @param newEntry the new entry

* @return true, if successful

*/

boolean insertTail(T newEntry);

/**

* Delete head.

*

* @return the t the object that has been deleted

*/

T deleteHead();

/**

* Delete tail Element.

*

* @return the t the object that has been deleted

*/

T deleteTail();

/**

* Display the list.

*/

void display();

/**

* check List Contains entry or not.

*

* @param anEntry the an entry

* @return the position of the entry that was found

*/

int contains(T anEntry);

/**

* Checks if List is empty.

*

* @return true, if is empty

*/

boolean isEmpty();

/**

* Checks if List is full.

*

* @return true, if is full

*/

boolean isFull();

} // end EntryWayListInterface

Thanks a lot.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote