This assignment will help you get practice with:

    Abstract Data Types
    Inheritance
    Polymorphism
    C++ pointers
    C++ Classes
    C++ virtual and pure virtual functions
    C++ Class Templates
    C++ Arrays

Task:
A container class is a data type that is capable of holding a collection of items and provides
functions to access them. Bag is an example of a container class. It is an unordered collection of
items that may have duplicates.
In this assignment, you are asked to design and develop an abstract Bag class, called
BagInterface, with the following fixed collection of operations:

    Insert an item of any type into a bag
    Query the bag contents: two queries
        Is an item in the bag?
        How many copies of an item is in the bag?
    Remove an item from the bag
    clear the bag
    Get the size of the bag
        How many items are there in the bag?
    Check if the bag is empty
    Check if the bag is full
    Assume the bag capacity is 20

In addition to BagInterface, you are asked to implement two classes of bag
implementations: PlainBag and MagicChangeBag.

PlainBag is a simple container that holds items of any type using an array implementation.

MagicChangeBag is also very similar to PlainBag, with two exceptions. When an item is inserted into a magic change bag, it’ll magically disappear, and bag looks empty. Whenever a remove operation is invoked, all the items, except the one is removed will appear.

You are given the following [AssignmentBag.cpp]

Download AssignmentBag.cpp] (contains the main function) diver application together with a sample run.

To do:

    Create BagInterface abstract class
    Implement PlainBag and MagicChangeBag classes
    Use templates
    Use virtual and pure virtual functions
    Use arrays
    Provide UML class diagram for your solution

Important Notes:

    You are not allowed to modify main.cpp implementation. Please use it as it is.
    Before you submit your work, please make sure the entire folder works.
    You are not required to handle the edge cases in this assignment.

    BagInterface.h
    PlainBag.h and PlaingBag.cpp
    MagicChangeBag.h and MagicChangeBag.cpp

main()
//main.cpp--See sample run located after the main function
#include <iostream>
#include "PlainBag.h"
#include "MagicChangeBag.h"
using namespace std;
template <class T>
void testBag(BagInterface<T>& bag) {
T value;
T item1 = 1;
T item2 = 2;
for (int i = 0; i < 20; i++) {
value = rand() % 6 + 1; //assume storing integers for sake of
simplicity
bag.insert(value);
}
bag.print();
cout << "\nNumber of items:" << bag.size();
cout << "\nNumber of ones:" << bag.itemCount(item1);
bag.remove(item1);
bag.print();
cout << "\nNumber of items:" << bag.size();
cout << "\nNumber of ones:" << bag.itemCount(item1);
cout << "\nNumber of twos:" << bag.itemCount(item2);
};
int main()
{
cout << "\n..............................." << endl;
cout << "Testing Plain Bag" << endl;
BagInterface<int>* bag = new PlainBag<int>;
testBag(*bag);
cout << "\n..............................." << endl;
cout << "Testing Magic Change Bag" << endl;
bag = new MagicChangeBag<int>;
testBag(*bag);
return 0;
}
/*
Sample Run:
Testing Plain Bag
Bag content:2 2 6 3 5 3 1 3 6 2 1 6 1 3 4 6 2 2 5 5
Number of items:20
Number of ones:3
Bag content:2 2 6 3 5 3 3 6 2 1 6 1 3 4 6 2 2 5 5
Number of items:19
Number of ones:2
Number of twos:5
...............................
Testing Magic Change Bag
Bag content:
Number of items:0
Number of ones:0
Bag content:4 2 4 6 5 4 4 1 3 2 2 3 3 2 3 4 2 2 4 4
Bag content:4 2 4 6 5 4 4 3 2 2 3 3 2 3 4 2 2 4 4
Number of items:19
Number of ones:0
Number of twos:6
do it in header and cpp file