Answered step by step
Verified Expert Solution
Question
1 Approved Answer
1 . sequence 1 . h: The header file for the sequence class. Actually, you don t have to write much of this file. Just
sequenceh: The header file for the sequence class. Actually, you dont have to write much of this file. Just start with our version and add your name and other information at the top. Also, decide on appropriate private member variables, an declare these in the sequence class definition at the bottom o the header file If some of your member functions are implemented as inline functions, then you may put those implementations in this file too.
sequencecxx: The implementation file for this first sequence class. You will write all of this file, which will have the implementations of all the sequences member functions. Other files that you may find helpful:
sequencetest.cxx: A simple interactive test program.
sequenceexam.cxx: A noninteractive test program that will be used to grade the correctness of your sequence class. The sequence Class Using a FixedSized Array
Discussion of the Assignment
Many of the features of this class are similar to the bag class from Section so start by thoroughly reading Section 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 of the class text. Notice how the sequence differs from a bag see page The interactive test program sequenceexam.cxx is discussed in Section of the class text. Start by declaring the sequences private member variables in sequence.h Then write the invariant of your ADT at the top of sequencecxx 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.
Use the interactive test program and a debugger to track down errors in your implementation. If you have an error, do not start making changes until you have identified the cause of the error.
The ability to initialize and use a static member constant within the class definition is a relatively new feature. If you have an older compiler that does not support static const members, then you may use enum CAPACITY ; instead of static const sizetype CAPACITY ;
after this definition, the name bag::CAPACITY is defined to have the integer value Although this is not the intended use of an enum definition, the result is the same as using a static member constant.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started