subject

namespace main_savitch_3{ // CONSTRUCTOR sequence::sequence() { counting = 0; occupied = 0; } // MODIFICATION MEMBER FUNCTIONS// 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). void sequence::start() { counting = 0; }// 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. void sequence::advance() { assert(is_item()==true); if(occupied==counting) { arr[counting]=0; counting++; } else { arr[counting]=arr[counting+1]; counting++; } }// void insert(const value_type& entry)// 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// inserted item is now the current item of the sequence. void sequence::insert(const value_type& entry) { assert (size()< CAPACITY); if (is_item() == false){ counting=0;} for (int i= occupied; i>counting;i--) { arr[i] = arr [i-1]; } arr[counting]= entry; occupied++; }// void attach(const value_type& entry)// Precondition: size( ) < CAPACITY.// Postcondition: A new copy of entry has been inserted in the sequence after// the current item. If there was no current item, then the new entry has// been attached to the end of the sequence. In either case, the newly// inserted item is now the current item of the sequence. void sequence::attach(const value_type& entry) { assert (size()< CAPACITY); if (is_item() == false){ arr[occupied-1]= entry;} for (int i= occupied; i> counting; i--) { arr[i]= arr[i+1]; } arr[counting]= entry; occupied++; }// void remove_current( )// Precondition: is_item returns true.// Postcondition: The current item has been removed from the sequence, and //the item after this (if there is one) is now the new current item. void sequence::remove_current() { assert(is_item()== true); for (int i= counting + 1; i< occupied - 1; i++) { arr [i]= arr[i+1]; occupied--; } } // CONSTANT MEMBER FUNCTIONS// size_type size( ) const// Postcondition: The return value is the number of items in the sequence. sequence::size_type sequence::size() const { return occupied; }// bool is_item( ) const// Postcondition: A true return value indicates that there is a valid// "current" item that may be retrieved by activating the current// member function (listed below). A false return value indicates that// there is no valid current item. bool sequence::is_item() const { if (counting < occupied) return true; else return false; }// value_type current( ) const// Precondition: is_item( ) returns true.// Postcondition: The item returned is the current item in the sequence. sequence::value_type sequence::current() const { assert(is_item()==true); return arr[counting]; }}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 03:00
With editing, word automatically displays a paste options button near the pasted or moved text. a. cut-and-paste b. drag-and-drop c. inline d. copy-and-carry
Answers: 1
question
Computers and Technology, 24.06.2019 21:30
The hybrid uses 144 to 158 volt batteries.
Answers: 1
question
Computers and Technology, 24.06.2019 22:00
Need getting google account back, big issue
Answers: 2
question
Computers and Technology, 25.06.2019 05:00
7. the cullerton park district holds a mini-olympics each summer. create a class named participant with fields for a name, age, and street address. include a constructor that assigns parameter values to each field and a tostring() method that returns a string containing all the values. also include an equals() method that determines two participants are equal if they have the same values in all three fields. create an application with two arrays of at least eight participants each—one holds participants in the mini-marathon, and the other holds participants in the diving competition. prompt the user for participant values. after the data values are entered, display values for participants who are in both events. save the files as participant.java and twoeventparticipants.java.
Answers: 2
You know the right answer?
namespace main_savitch_3{ // CONSTRUCTOR sequence::sequence() { counting = 0; occupied = 0; } // MOD...
Questions
question
Mathematics, 07.04.2021 19:20
question
English, 07.04.2021 19:20
question
English, 07.04.2021 19:20
question
Mathematics, 07.04.2021 19:20
Questions on the website: 13722363