This website is preserved for historical and scholarly reference and is no longer actively maintained.
                         CpSc 210, Section 1
                             Assignment 5 
                            October 7, 2002 



Due:  Wednesday, October 16 at 11:59 p.m.  

Assignment:  Write an extenstion of Bailey's Vector class that creates
    a new method to replace the contains method in Bailey's class.
    The name of your class must be ExtendedVector and this class is
    to be contained in a file named ExtendedVector.java.

    You will also need to write at least one constructor for
    the ExtendedVector class.  Remember where you found the URL
    for Bailey's code and go to "View the local source" to find
    his code for the Vector class.              

    You will also need to change the direction of the search in the
    contains method in order that the code be efficient.     

Total point value of assignment:  50 points
Not accepted late.

This assignment is to be done INDIVIDUALLY.


     import structure.Vector;

     public class ExtendedVector extends Vector
     {
        // constructor(s) for Extended Vector

        public boolean contains ( Object elem )
        // post:  returns true and moves elem to the end of the Vector
        //        iff Vector contains the value
        {
           ... your code here
        }

        public static void main ( String [ ] args )
        // test code for Extended Vector
        {
           ExtendedVector myVec = new ExtendedVector ( );
           // etc. 
        }
      } 


     Example 1.  If the ExtendedVector, myVec, contains elements in the
     order 'a','b','c','d' then myVec.contains(new Character('b'))
     should return true and alter the order to 'a','c','d','b'.

     Example 2.  If the ExtendedVector, myVec, contains elements in the
     order 'x','y','z' then myVec.contains(new Character('b')) 
     should return false and the Vector is not changed.

     Example 3.  If the ExtendedVector, myVec, contains elements in the
     order 20,25,30,45 then myVec.contains(new Integer(20)) returns
     true and the order of the elements is changed to 25,30,45,20.

Grading Rubric:

	5 pts. reasonable attempt to solve problem as assigned
	5 pt. also compiles
	5 pts. style standards (includes clarity)
       (1) Your name must be printed as a comment at the beginning of file.
       (2) A description of what this program does must immediate follow name.
       (3) Indent exactly 3 or 4 spaces.  Be consistent.  See handout examples.
       (4) Every Java statement must begin on a separate line.
       (5) The first operation of your program must be to print your name,
           followed by "CPSC 210", the assignment number, and a description 
           of what program does.
       (6) A comment must immediately follow all while, do, or for loops
           giving the condition that is true after loop exit.

    The following 35 points are available only for code that compiles 
    and runs without error. 

      5 pts. constructor.  If constructor doesn't work, nothing else will.    
      5 pts. Example 1 gives correct result
      5 pts. Example 2 gives correct result
      5 pts. Example 3 gives correct result
      5 pts. program works correctly (with our code).  
     10 pts. overall quality of program  (i.e., ease of reading and
            understanding code, choice of code statements, etc.)


Other requirements: Follow the style standards to be found on your instructor's web page for CPSC 210. Submit your program using the handin command. There is a link to the handin description on the CPSC 210 lab page (www.cs.clemson.edu/~lab210).