Question: Use the ArrayBag class structure. Implement a menu of options that uses the member functions defined in the class. Search based on an ID you
Use the ArrayBag class structure.
Implement a menu of options that uses the member functions defined in the class.
Search based on an ID you assign for each speaker.

ArrayBag.h
#ifndef _ARRAY_BAG
#define _ARRAY_BAG
#include "BagInterface.h"
template
class ArrayBag : public BagInterface
{
private:
static const int DEFAULT_CAPACITY = 6;
ItemType items[DEFAULT_CAPACITY];
int itemCount;
int maxItems
int getIndexOf(const ItemType& target) const;
public:
ArrayBag();
int getCurrentSize() const;
bool isEmpty() const;
bool add(const ItemType& newEntry);
bool remove(const ItemType& anEntry);
void clear();
bool contains(const ItemType& anEntry) const;
int getFrequencyOf(const ItemType& anEntry) const;
vector
};
#include "ArrayBag.cpp"
#endif
ArrayBag.cpp
#include "ArrayBag.h"
#include
template
ArrayBag
{
}
template
int ArrayBag
{
return itemCount;
}
template
bool ArrayBag
{
return itemCount == 0;
}
template
bool ArrayBag
{
bool hasRoomToAdd = (itemCount
if (hasRoomToAdd)
{
items[itemCount] = newEntry;
itemCount++;
}
return hasRoomToAdd;
}
template
bool ArrayBag
{
int locatedIndex = getIndexOf(anEntry);
bool canRemoveItem = !isEmpty() && (locatedIndex > -1);
if (canRemoveItem)
{
itemCount--;
items[locatedIndex] = items[itemCount];
}
return canRemoveItem;
}
template
void ArrayBag
{
itemCount = 0;
}
template
int ArrayBag
{
int frequency = 0;
int curIndex = 0;
while (curIndex
{
if (items[curIndex] == anEntry)
{
frequency++;
}
curIndex++;
}
return frequency;
}
template
bool ArrayBag
{
return getIndexOf(anEntry) > -1;
}
template
vector
{
vector
for (int i = 0; i
bagContents.push_back(items[i]);
return bagContents;
}
template
int ArrayBag
{
bool found = false;
int result = -1;
int searchIndex = 0;
while (!found && (searchIndex
{
if (items[searchIndex] == target)
{
found = true;
result = searchIndex;
}
else
{
searchIndex++;
}
}
return result;
}
BagInterface.h
#ifndef _BAG_INTERFACE
#define _BAG_INTERFACE
#include
using namespace std;
template
class BagInterface
{
public:
virtual int getCurrentSize() const = 0;
virtual bool isEmpty() const = 0;
virtual bool add(const ItemType& newEntry) = 0;
virtual bool remove(const ItemType& anEntry) = 0;
virtual void clear() = 0;
virtual int getFrequencyOf(const ItemType& anEntry) const = 0;
virtual bool contains(const ItemType& anEntry) const = 0;
virtual vector
};
#endif
9. Speakers' Bureau structure to store the following data about a speaker: Name Telephone Number Speaking Topic Fee Required The program should use an array of at least 10 structures. It should let the user enter data into the array, change the contents of any element, and display all the data store in the array. The program should have a menu-driven user interface. Input Validation: When the data for a new speaker is entered, be sure the user enters data for all the fields. No negative amounts should be entered for a speaker's fee
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
