Question
**************header file********* sequence1.h******************* ****************************Implementation file *****************sequence1.cpp**************** #include #include #include using namespace std; namespace main_savitch_3 { // no argument constructor sequence::sequence() { used = 0; current_index
**************header file*********
sequence1.h*******************
****************************Implementation file
*****************sequence1.cpp****************
#include
#include
#include
using namespace std;
namespace main_savitch_3
{
// no argument constructor
sequence::sequence()
{
used = 0;
current_index = 0;
}
void sequence::start( )
{
current_index = 0;
}
void sequence::advance( )
{
//Implementation goes here
}
void sequence::insert(const value_type& entry)
{
assert(size()
if(!is_item())
{
current_index = 0;
}
if(size() > 0)
{
for(int i = size(); i > current_index; i--)
{
data[i] = data[i-1];
}
}
data[current_index] = entry;
used++;
}
void sequence::attach(const value_type& entry)
{
// implementation goes here
}
void sequence::remove_current( )
{
//implementation goes here
}
// CONSTANT MEMBER FUNCTIONS
sequence::size_type sequence::size( ) const
{
return used;
}
bool sequence::is_item( ) const
{
return used > current_index;
}
sequence::value_type sequence::current( ) const
{
return data[current_index];
}
}
please include the completed incrementation file with the new functions mentioned above. thank you
The purpose of this lab is to help reinforce container class concepts in C++ Specifically, the lab is to implement the sequence class from chapter 3. You should use the author's header file sequencel.h and the author's test program sequence_exam.cpp) You are provided with a partially implemented file sequencel.cpp. Please implement the following functions based on the pre and post conditions listed in the header file for this class. void advance0 void attach(const value _type& entry) void remove current0 > hi sequence 1.h) No Selection 1 // FILE: sequence1.h 2 II CLASS PROVIDED: sequence (part of the namespace main savitch_3) 3 // There is no implementation file provided for this class since it is 4 // an exercise from Section 3.2 of "Data Structures and Other Objects Using C++" 6 I/ TYPEDEFS and MEMBER CONSTANTS for the sequence class: 7 /1 typedef value_type sequence::value type is the data type of the items in the sequence. It 9 IImay be any of the C++ built-in types (int, char, etc.), or a class with a default constructor, an assignment operator, and a copy constructor 12 Itypedef 13/ size type sequence::size_type is the data type of any variable that keeps track of how many items are in a sequence. 16 IIstatic const size type CAPACITY sequence: :CAPACITY is the maximum number of items that a sequence can hold. 18/ 19 I/ CONSTRUCTOR for the sequence class: 20 I1sequence) 21 Postcondition: The sequence has been initialized as an empty sequence. 23 // MODIFICATION MEMBER FUNCTIONS for the sequence class: 24 Ivoid start() Postcondition: The first item on the sequence becomes the current item (but if the sequence is empty, then there is no current item). 27 11 28 void advance() Precondition: is item returns true Postcondition: If the current item was already the last item in the sequence, then there is no longer any current item. Otherwise, the new current item is the item immediately after the original current item. 32 / 33 / 34 IIvoid insert (const value_type& entry) Precondition: size( )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