Class MyVector

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--MyVector
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class MyVector
extends java.util.Vector

Adds methods to pick elements from a vector

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
MyVector(int argSize)
          Mimic the superclass constructor
 
Method Summary
 java.lang.Object findByName(java.lang.String name)
          Find an element in the vector given its name
(package private)  java.lang.Object randomEntry()
          Selects an element at random from the vector
 java.lang.Object select(java.lang.String prompt)
          Displays a window showing the elements of the vector in order, allows the user to select one, and returns the result, or null.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

MyVector

public MyVector(int argSize)
Mimic the superclass constructor
Method Detail

findByName

public java.lang.Object findByName(java.lang.String name)
                            throws CantFindObjectException
Find an element in the vector given its name
Parameters:
a - case-insensitive name for which we want to search
Returns:
the object found
Throws:
CantFindObjectException - if no matching object is found

randomEntry

java.lang.Object randomEntry()
Selects an element at random from the vector
Returns:
the randomly-chosen element, or null if the vector has no elements

select

public java.lang.Object select(java.lang.String prompt)
Displays a window showing the elements of the vector in order, allows the user to select one, and returns the result, or null.
Parameters:
prompt - a title for the selection window
Returns:
the selected object, or null if the user cancelled from the selection window