Home / Expert Answers / Computer Science / only-edit-sections-labeled-34-to-do-34-in-c-below-are-the-grocery-list-cpp-and-main-file-below-nbsp-pa895

(Solved): Only edit sections labeled "TO-DO" in C++. Below are the grocery list cpp and main file below.  ...



Only edit sections labeled "TO-DO" in C++. Below are the grocery list cpp and main file below. 

Queries
?
( size() const
std::size_t GroceryList:isize() const
1/ Verify the internal grocery list state is still consistent \( f / \) Accessors
\( / 1 \)
\( / f \) find() const
std:ssize_t GroceryList: find( const GroceryItem a groceryItem ) Lanst
/137 insert ottset )
6. Iten at affsetfromTap
141 / \( / / \) offsets, and an offset equalent size is an orror.
143 144
160 / if ( offsetfrontop s= sizel) ) return; \( \quad / / \) no change occurs if (zero-based bffsetfromTop \( >= \) sizel)
(1) HMM

4
3
\( f l \) operatorom innit?alizer_list?
1\( / / \) verify the internal gracery list state is still consistent amongst the four containers.
if( !containergareConsistan

GroceryList) No Selection
// for each grocery item in the provided grocery list, insert the grocery item into the provided st

int main()
\( \operatorname{try} \)
\{ basicscenar?o\{\};
Greate, manipulate, and display your own GroceryList object here, N

 

Queries ? ( size() const std::size_t GroceryList:isize() const 1/ Verify the internal grocery list state is still consistent amongst the Four containers Al the containers are the same size, 50 pick one and retum the size of that. Since the forward_list hess to calculate the ?7 / cessors (/ findl) const Std::size_t GroceryList:ifind const GroceryItem \& groceryItem J const // Verify the internel grocery list state is still consistent amongst the four containers it( [ containersareconsistant()) throw GroceryList:: Invalidinternalstate_Ex( 'Container consistency error' exception_location ;; Locale the grocerry ilem in this grocery list and return the zero-based position of that grocery ilem. II the grocery itern be in the same position in all the containers (array, wector, list, and forward listi) so pick just one of those to snarch. The STL provides the tinde) function that is a perfect fit here, but you may also write your own loop. \( f / \) Accessors \( / 1 \) \( / f \) find() const std:ssize_t GroceryList: find( const GroceryItem a groceryItem ) Lanst /. Verify the internal grocery list state is still consistent amongst the four containers Locate the grocery item in this grocery list and return the zero-based position of that grocery item. If the grocery item /. does not exist, return the size of this grocery list as an indicator the grocery liem does not exist. The grocery item will /f be in the same position in all the containers (array, vector, list, and torward_list) so pick just one of those to search. If The STL provides the findi) function that is a perfect fit here, but you may also write your awn loop. \( f / \) Modifiers 18 \( f / \) insert( position ) void Grocerylistainsert( const GroceryItem g groceryItem, Pasition position) 137 insert ottset ) 6. Iten at affsetfromTap 141 / \( / / \) offsets, and an offset equalent size is an orror. 143 144 160 / \( / / \) is the same. \( A \) check is macle at the end of this function to verify the contents of all four containers are indeed the same. 165 / \( 1 / \) Hint: 'Vector.hpp" in our Sequence Container Implamentation Examples shows you how to do this. (wink wink) 168 \( / / / \) Unilike the other containera, an atd : array has tixed capacity and fixed aize (and aize is alwaya == capacity) hence has no 169 / \( / / \) inserti) tunction, so you have to writte it youreelt. Insert into the array by shifting all the items at and after the \( 170-\quad / / \) insertion point (offsetFrom Top) to the right opening a gap in the array that can be populated with the given grocery item. 171 I Remember that arrays have flixed capacity and cannot grow, so make sure there is room in the array for another grou 172 before you start by verilying gList array size (the number of valid elements) is less than gList array.sizel) \{the 134 /if in your array, so dont forget to adjust_gList_array_size. 176 - \( l / / \) Open a hols to insert new grocery item by shitting to the right everything at and atter the insertion point. 177 / \( / / \) For example: \( \mathrm{a}[\mathrm{B}]=\mathrm{a}[7] ; a[7]=a[6] ; a[6]=a[5] \); and so on. 178 l \( l / / \) std: move_beckward will be helpful, or write your own loop. \( 181 \quad \) b \( / / \) Part 1 - Insert into array if ( offsetfrontop s= sizel) ) return; \( \quad / / \) no change occurs if (zero-based bffsetfromTop \( >= \) sizel) (1) HMM 4 3 \( f l \) operatorom innit?alizer_list? 1 \( / / \) verify the internal gracery list state is still consistent amongst the four containers. if( !containergareConsistant()) throw GroceryList:: InvalidInternalstate_Ex( 'Container consistency errar' exception_location ; return *this 3 GroceryList) No Selection // for each grocery item in the provided grocery list, insert the grocery item into the provided stream, Each grocery iten is \( / / \) inserted on a new line and preceded with its index (aka offset from top) unsigned count \( =\mathrm{B} \); return stream; 3 \( f l \) operatorbs std:iistrean \& operator> [ std:istream \& stream, GroceryList \& groceryList) \( f / \) Extract until end of file grocery items from the provided stream and insert them at the bottom of the provided grocery list. \( / / / \) Ea sure to extract grocery ilems and not individual lields such as product name or UPC. return stream; 3 int main() \( \operatorname{try} \) \{ basicscenar?o\{\}; Greate, manipulate, and display your own GroceryList object here, Not looking for anything specific but don' just repeat what live already done above. Be imaginative and create your own story. Maybe youre restocking a dapleted food bank, or If preparing for a holidey meal, or catering a banquete, or planning an all night stucly eassion, or ... You *must" use al 1/ the tunctions of the GroceryLiat intertace, including the insertion, extraction, and relationel cperators. Try ingerting If grocery items from both the top and the bottom of the lists using the enumerated poeition values TOP and BOTTOM as well as If Indexed oftsets. Remove grocery ltems trom the top, midide, and bottom. Create, concatenate, rearrange, and compare if several (more than two) lists. Have some fun with it. The 77. (i.e., the clienti) undersiand haw to "use' the Grocerylist. catch [ const std:; exception \& ex 1 \( \ll \) ex.what \{\}\( < \) \& 1,7 '? 3


We have an Answer from Expert

View Expert Answer

Expert Answer


#include using namespace std; const int m=50; class items { int itemcode[m]; float itemPrice[m]; int count; public: void CNT() { count = 0;
We have an Answer from Expert

Buy This Answer $2

Place Order

We Provide Services Across The Globe