Question: import org.javatuples.Pair; / * * * Abstract * @param Generic type * / public abstract class MyAbstractList implements MyList { / * * * The

import org.javatuples.Pair;
/**
* Abstract
* @param Generic type
*/
public abstract class MyAbstractList implements MyList {
/**
* The size of the list.
*/
protected int size =0;
/** Create a default list */
protected MyAbstractList(){
}
/** Create a list from an array of objects
* @param objects Array of the specified generic type
*/
protected MyAbstractList(E[] objects){
for (E object : objects){
set(size,object);
}
}
/** Return true if this list contains no elements */
public boolean isEmpty(){
return size ==0;
}
/** Return the number of elements in this list */
public int size(){
return size;
}
/**
* This method determines whether an element is in the list or not.
* In the process of searching the list, it will keep a tally of comparisons (i.e. steps) it makes
* to find the given element. It returns a Pair containing a boolean, which expresses whether the
* element was found (true) or not (false) and an integer value showing the number of comparisons it took
* @param e element to be search for in the list
* @return pair containing a boolean and int. Boolean should be true if element is found. False otherwise.
* The number of comparisouns made to reach either conclusion is the integer
**/
public Pair contains(E e){
return new Pair<>(false,-1);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!