Question: // Write the definition of the client function below that replaces a given item (item ToReplace) in a given bag with another given item (replacementitem).

 // Write the definition of the client function below that replacesa given item (item ToReplace) in a given bag with another given

 

// Write the definition of the client function below that replaces a given item (item ToReplace) in a given bag with another given item (replacementitem). The function should return a boolean value to indicate whether the replacement was successful. Remember items in the bag are not stored in any particular order, so you do not need to be concemed with the position of new Value in the given bag! 1) boot replace(Bag&b, string itemToReplace, string replacementitem) 2) Il Write C++ client code to call the replace function to replace the string value of "ONE" with the string value "NONE" in yourBag. Write an output a statement to indicate whether or not the operation was successful. 2. Below is the class dcclaration for the Bag class from your text. Refer to this header file to answer parts a and b. /** ADT bag: Array-based implementation. @file Bag.h 7 #ifndef _BAG #define _BAG template class Bag private: static const int DEFAULT_BAG_SIZE = 6; Item Type items (DEFAULT_BAG_SIZE); Il array of Bag items int itemCount; Il current count of Bag items int maxitems; Il max capacity of the Bag // Returns either the index of the element in the array items that Il contains the given target or -1, if the array does not contain // the target. int getindexOf(const Item Type& target) const; public: l/construct an empty bag Bag(); //returns number of elements in the Bag int getCurrent Sizel ) const; //returns true if Bag is empty, false otherwise bool isEmpty() const; // adds newEntry to Bag bool add(const Item Type& newEntry); //removes first occurrence of anEntry from Bag bool remove(const Item Type& anEntry); Il empties the Bag void clear(); l/returns true if Bag contains anEntry, false otherwise bool contains(const Item Type& anEntry) const: Il returns the number of occurrences of anEntry in the Bag int getFrequency Of(const Item Type & an Entry) const; Il implementation NOT shown Meridif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!