import SimpleDate; import java.util.Vector; /** * Methods for affecting the elements of a vector. Ideally, these would * be provided by extending Vector class, but we may not yet have the * appropriate skills for doing so * * Warning! Some methods in the class are initially erroneous. * * @author Samuel A. Rebelsky * @author Your Name Here * @version 1.0 of January 1999 */ public class VectorMod { /** * Put all of the strings in the vector into all caps. */ public void allCaps(Vector vec) { int i; // Counter variable for loop String s; // A string found in the vector // Step thrugh the elements of the vector for(i = 0; i < vec.size(); ++i) { // if the ith element is a string if (vec.elementAt(i) instanceof String) { // then put the string into upper case s = (String) vec.elementAt(i); vec.setElementAt(s.toUpperCase(), i); } // if it's a string } // for each element of the vector } // allCaps(Vector) /** * Reset all of the dates in the vector to the beginning of * the month. */ public void firstOfMonth(Vector vec) { int i; // Counter variable for the loop SimpleDate d; // A date found in the vector // Step through the elements of the vector for (i=0; i < vec.size(); ++i) { d = (SimpleDate) vec.elementAt(i); vec.setElementAt(new SimpleDate(d.getYear(),d.getMonth(),1), i); } // for each element of the vector } // firstOfMonth(Vector) } // class VectorMod