Question: Using the prompt below and the files under that. Please write the code as instructed. Thank you Sequence_exam.cpp Sequence 1.cpp Sequence1.h The purpose of this
Using the prompt below and the files under that. Please write the code as instructed. Thank you
Sequence_exam.cpp
Sequence 1.cpp
Sequence1.h
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 current) Move all files to the cloudland server and compile them using the following command: sequence exam.cpp sequencel cpp -o sequencel 13 finclude 14 include 15 finclude "sequence1.h" // Provides the sequence class with double items. 16 using namespace std: /Provides cout. // Provides size t. 17 using namespace main savitch 3: 18 19 // Descriptions and points for each of the tests: 20 const size_t MANY TESTS = 3; 21 const int POINTS [MANY TESTSt1 22 100, Total points for all testa. 23 50,/ Test 1 points 24 25, // Test 2 points 25 25 11 Tost 3 points 26 27 const char DESCRIPTION [MANY TESTS+111256) 28 29 "Testing insert, attach, and the constant member functions", 30 31 32 "tests for Chapter 3 sequence Clasa", "Testing situations where the cursor goes off the sequence", "Testing remove current" 34 35 /RARR 36 // bool test basic(const sequences test, size t s, bool has cursor) 37 1/ Postcondition: A return value of true indicates: Postcondition: A return value of true indicates: a. test.size) is s, and b. test.is item) is has cursor 38// Otherwise the return value is false. In either case, a description of the test result is printed to cout 40 41 42 43 bool test basic (const sequences test, size t s, bool has cursor) 44 ( 45 bool answer: 46 47 cout size, then test must not have a cursor. 123// NOTE: The function also moves the cursor off the sequence. 124 /AAANA** 125 bool correct (sequence& test, sizet size, size t cursor spot, double itema[l) 126 t 127 bool has_cursor (cursor spot 0) 431 int result: cout 2 #include 3 tinclude 5 using namespace std: 6 7 namespace main savitch 3 8 t 9 1I no argument constructor 10 sequence::sequence () used = 0; currentindex = 0; 12 13 14 15 16 - 17 void sequence: :start() 18 19 20 21 current index -0: 2 void sequence:: advance 23 24 25 26 27 28 29 30 31 32 //Implementation goes here assert (size)CAPACITY) if (!is_item)) currentindex = 0; - current index -0 34 35 if (size)> 0) 36 37 38 39 4 0 4 1 42 4 3 for (int i size i> current index: i-) datali] datali-11: data [current index]entry used++ 4 5 46 47 void sequence: :attach (const value type entry) 48 49 50 51 52 53 void sequence: :remove current () 54 // implementation goes here //implementation goes here 56 57 58 59 CONSTANT MEMBER FUNCTIONS 60 sequence::size type sequence: size 61 62 63 54 const 60 sequence: :size type sequence::size( return used; 55 bool sequence::is item() const 67 68 69 70 71 72 73 74 J return used current indexi sequence::value_ type sequence: :current () const return data[current index] 1 / FILE: sequencel.h 2 1 CLASS PROVIDED: sequence (part of the namespace main savitch 3) 3// There is no implementation file provided for this class since it is 4 11 an exercise from Section 3.2 of "Data Structures and Other objects Using C+t 6 7 TYPEDEFS and MEMBER CONSTANTS for the sequence class typedef value type sequence : :value type is the data type of the items in the sequence. It 911may be any of the C+ built-in types (int, char, etc.), or a class with a 10default constructor, an assignment operator, and a copy constructor. 12 typedef size_type sequence: :size type is the data type of any variable that keeps track of how many items are in a sequence. 16/ static const size_ type CAPACITY 17. // sequence :: CAPACITY S the maximum number of items that a sequence can hold. 19 // CONSTRUCTOR for the sequence class: 20 sequence() Postcondition: The sequence has been initialized as an empty sequence 23 / MODIFICATION MEMBER FUNCTIONS for the sequence class: 24 / void 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 281void advance() 29 Precondition: in itom returns true 307/ 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. 31 7/ 34 void insert (const value_type& entry) 35 /7 Precondition: size(CAPACITY Postcondition: A new copy of entry has been inserted in the sequence before the current item. If there was no current item, then the new entry has been inserted at the front of the sequence. In either case, the newly 38/ 39 7 inserted item is now the current item of the sequence 41 void attach (const value type& entry) 43 7/Postcondition: A new copy of entry has been inserted in the sequence after Precondition: size( ) / Provides size t 73 74 namespace main savitch 3 75 1 - - class sequence 78 79 80 81 82 83 8 4 85 86 87 public: / TYPEDEFS and MEMBER CONSTANTS typedef double value type: typedef std::size t size type: static const size type CAPACITY 30 CONSTRUCTOR sequence ( 89 90 91 92 93 94 95 private: 96 97 98 MODIFICATION MEMBER FUNCTIONS void start void advance void insert (const value type& entry) void attach (const value types entry) void remove current // CONSTANT MEMBER FUNCTIONS size type size() const: bool is_item const value type current) const value_type data (CAPACITY] size type usedi size_type current_index ) i 100 101 102 #endif 103 104