CS 24, Fall 2016

Programming Assignment 3

Due: Friday, October 28, 11:59pm
Worth: 100 points

PA3 can be done either in two-people teams or individually.

If you are working with a partner, be sure that both partners' names are in a comment at the top of the source code file, and that you properly form a group for this project in the submit.cs system.

  1. Implement a new version of class sequence, one without a capacity constraint. Your implementation must be in a new file that you create named sequence2.cxx.
    • Type your name(s) and the date in a comment at the top of sequence2.cxx.
    • You must implement each of the member functions (including both constructors, the destructor and the assignment operator) of class sequence - as they are defined in this class header file: sequence2.h - first download a copy of this header file, and store it in your working directory for this project.
    • Probably you will want to begin with your PA2 solution, and in fact we recommend it. If you were unsuccessful implementing the first version of class sequence, then we highly recommend going back and fixing your work on that implementation now, before attempting this upgrade.
    • Here are the basic differences between a sequence with a fixed size array and a sequence that uses a dynamic array (as worded by Michael Main textbook author):
      • The number of items which may be stored in the sequence should only be limited by the amount of memory available on the heap. When new items are added to a sequence which is at capacity, the size of the data array in which items are stored should be automatically enlarged.
      • The constructor should have a default argument which allows the user to set the initial capacity of the sequence.
      • Because you are dynamically allocating memory within your sequence class, you will need to define a copy constructor, an assignment operator, and a destructor.
      • There should be a resize function that allows the user to explicitly set the capacity of the sequence.
      And that about sums it up! Thank you Professor Main.
    • As this conversion is very similar to the one you did for class Words in Lab04, you can refer back to that lab for general guidance.
    • We suggest you also refer to the textbook's conversion of the bag class from using a fixed size array (bag1) to using a dynamic array (bag2), as that implementation contains many parts you are likely to find useful.
  2. Compile and test your program at CSIL. Perform basic unit tests with the same interactive test program you used for PA2 (sequence_test.cxx) - just edit the #include and using directives the way you did for Lab04. Then when you are satisfied that your implementation is able to pass basic tests, run all seven of the tests from the non-interactive test program that will be used by submit.cs to score your work: sequence_exam2.cxx. Run it by giving a test number between 1 and 7 as a command line argument. For example, the following commands demonstrate compiling this non-interactive program, and then running test3 with it:
    g++ -std=c++11 -o sequence_exam2 sequence2.cxx sequence_exam2.cxx
    ./sequence_exam2 3
  3. Submit PA3 at https://submit.cs.ucsb.edu/, or use the following command from a CS terminal:
    ~submit/submit -p 564 sequence2.cxx
    Be sure to wait for the results of all seven tests. If you score 100/100 and you've followed all of the other rules, then you'll earn full credit.

Updated 10/17/2016, by C. Michael Costanzo.
Special thanks to Michael Main, University of Colorado, creator of most parts of this project.