Learning ADT lists
how do I implement these 3 methods contains(), remove() and clear().
public boolean contains(T item);
// Determines if a certain item is in the list.
// Precondition: an item which need to be compared
// Postcondition: Returns true if there is the same item in the list
// Return false if there is not the same item in the list
public boolean remove(int position);
// Deletes an item from the list at a given position.
// Precondition: position indicates where the deletion should occur.
// Postcondition: If 1 <= index <= size(), the item at a given position
// in the list is deleted, other items are renumbered
accordingly
// and, it returns true.
// Returns false if index < 1 or index > size()+1
// or the list is empty
public void clear();
// Deletes all the items from the list.
// Precondition: None.
// Postcondition: The list is empty.
} // end ListInterface
public class ADTList<T> implements ListInterface<T>{
private T array[];
private int numItems;
public ADTList(){
//create an empty array
array = (T[]) new Object[10];
// assign 0 to numItems;
numItems=0;
}
}
public boolean contains(T item){
System.out.println("You need to implement it");
return true;
}
public boolean remove(int position){
System.out.println("You need to implement it");
return true;
}
public void clear(){
System.out.println("You need to implement it");
}
}
if someone could show me how to do one of these 3 methods I think I can
figure out the other two. Thanks in advance for any help offered.