Question: need help with this c++ program... Your job for this assignment is to build a Special Bag data type. The special bag data type will

need help with this c++ program...

Your job for this assignment is to build a "Special Bag data type.

The special bag data type will be implemented as follows:

1. Objects can be inserted into the magic bag using the SpecialBag::insert(item) member function. The special bag can hold any number of items, Duplicate items are allowed.

2. Objects are removed from the magic bag using the SpecialBag::draw() member function. This function returns a random item and removes it from the bag. The returned item should be randomized. In other words, if there are 5 items in the bag, and only one of them is a 7, then there should be a 1 in 5 chance of drawing a 7 with the draw() function. If the bag is empty, the draw() function should throw an exception.

3. You can check if an object is in the bag using SpecialBag::peek(item), which should return 0 if there is no item in the bag matching the item parameter. If there are items matching the item parameter in the bag, the number (count) of matching items should be returned.

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!