Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finish the Implementation of the Sequence class. Test your implementation by running the following set of commands: 1.Create sequence called seq; 2.Insert numbers 5, 2,

Finish the Implementation of the Sequence class.

Test your implementation by running the following set of commands:

1.Create sequence called seq;

2.Insert numbers 5, 2, 200, -3.0, 45, -55.5

3.Print out sequence

4.Remove the -3.0

5.Print out sequence

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

sequence.h

// FILE: bag1.h #ifndef MAIN_CONTAINERS_H #define MAIN_CONTAINERS_H #include  // Provides size_t #include  using namespace std; namespace main_containers { class sequence { public: // TYPEDEFS and MEMBER CONSTANTS typedef double value_type; typedef std::size_t size_type; static const size_type CAPACITY = 30; // CONSTRUCTOR sequence( ) {} // MODIFICATION MEMBER FUNCTIONS void start(); void advance(); void insert(const value_type& entry); void attach(const value_type& entry); void remove_current(); // CONSTANT MEMBER FUNCTIONS size_type size( ) const { return used; } bool is_item() const; value_type current() const; private: value_type data[CAPACITY]; // The array to store items size_type used; // How much of array is used size_type current_index; // Index of current item }; // NONMEMBER FUNCTIONS for the sequence class } #endif 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

sequence.cpp

#include  // Provides copy function #include  // Provides assert function #include "sequence.h" using namespace std; namespace main_containers { const sequence::size_type sequence::CAPACITY; void sequence::remove_current() { size_type i; if (!is_item()) current_index = 0; for (i = current_index; i 

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

HW_sequence.cpp

#include  #include  #include "sequence.cpp" using namespace std; using namespace main_containers; int main ( int argc, char *argv[] ) { // the sequence for the HW is 5, 2, 200, -3.0, 45, -55.5 // I have started the testing specificed in the HW for you. sequence numbers; numbers.start(); numbers.insert(5); // Continue your testing here. } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions