Programming and Problem Solving with Java

(やまだぃちぅ) #1
733

publicListWithDuplicates()
// Instantiate an empty list object with room for 100 items
{
numItems = 0 ;
listItems = newString[ 100 ];
currentPos = 0 ;
}


publicListWithDuplicates(intmaxItems)
// Instantiate an empty list object with room for
// maxItems items
{
numItems = 0 ;
listItems = newString[maxItems];
currentPos = 0 ;
}


public booleanisFull()
// Return true if there is not room for another component;
// false otherwise
{
return(listItems.length == numItems);
}


public booleanisEmpty()
// Return true if there are no components in the list;
// false otherwise
{
return(numItems == 0 );
}


public intlength()
// Return the number of components in the list
{
returnnumItems;
}
public abstract booleanisThere(String item);
// Return true if item is in the list


// Transformers
public abstract voidinsert(String item);
// If the list is not full, insert item into the list;
// otherwise, list is unchanged

Free download pdf