pa02 : Sequence class

num ready? description assigned due
pa02 true Sequence class Tue 04/18 09:00AM Fri 04/28 11:59PM

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

If you are working with a partner, don’t just split up the work! Pair programming means working together to solve each of the problems: trust us that it will work more smoothly for you if you do it like that anyway. Also 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.

  • We highly recommend that you create a repo on github. Follow the naming convention from lab01, replacing the prefix lab01 with pa02.

  • Add your partner as a collaborator on github

  • Clone your repo in your COE account on the CSIL servers

  • Do a git pull to get the latest starter code

    cd ~/cs24/starter-code/pa02
    git pull
    

    Copy the starter code from the ~/cs24/starter-code/pa02 directory to your github repo.

Implement the class sequence from Figure 3.9 on page 129 of the textbook. Your implementation must be in a new file that you create named sequence1.cxx. Type your name(s) and the date in a comment at the top of sequence1.cxx. Your basic job is to implement each of the member functions (including the constructor) of class sequence - as they are defined in the class header file: sequence1.h. Be sure to #include sequence1.h in your implementation file. Useful tips from Michael Main (textbook author):

  • Many of the features of this class are similar to the Bag class from Section 3.1, so start by thoroughly reading Section 3.1 and pay attention to new features such as static constant members and the use of a typedef. The sequence class itself is discussed in Section 3.2 of the class text. Notice how the sequence differs from a Bag.

  • Write the invariant of your ADT at the top of sequence1.cxx. The invariant describes precisely how all of your private member variables are used. All of the member functions (except for the constructor) may count on the invariant being true when the member function is activated. And all of the member functions are responsible for ensuring that the invariant is true when the function returns.

  • As always, do your work in small pieces. For example, my first version of the sequence had only a constructor, start, insert, advance, and current. My other member functions started out as stubs. Compile and test your program at CSIL, using the interactive test program: sequence_test.cxx. It is exactly the same program discussed in section 3.3 of the textbook - read about it there. You can use the following command to compile it along with your implementation:

g++ -o sequence_test sequence_test.cxx sequence1.cxx

The point of this interactive test program is for you to test your functions individually, to make sure each one is working properly before running your implementation through more comprehensive tests like the ones that will be used when you submit. To learn details of those tests, see the non-interactive test program we will use: sequence_exam.cxx (you can try it out before submitting if you want - give 1 or 2 or 3 as a command line argument if you run it).

We have provided you a reference executable that was generated by compiling a correct implementation of the sequence class with the interactive test program. You may run it as follows to see how a correct program would behave with the interactive test program.

./refsequence

Submit PA2 at https://submit.cs.ucsb.edu/, or use the following command from a CS terminal:

~submit/submit -p 703 sequence1.cxx

Be sure to wait for the results of the three tests. If you score 100/100 and you’ve followed all of the other rules, then you’ll earn full credit. Also make sure you commit and push your code to github at every stage of developing your code.