Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me write this in C++ with use the ArrayBag class structure, implemen

ID: 2247082 • Letter: P

Question

Please help me write this in C++ with use the ArrayBag class structure, implement a menu of options that uses the member functions defined in the class and search based on an ID you assign for each speaker. Please write in computer, comments and organization. Do not be so advanced. Please make the output equal to the image. Include all program please (main,cpp and header).

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 toVector() const;

};

#include "ArrayBag.cpp"

#endif

ArrayBag.cpp

#include "ArrayBag.h"

#include

template

ArrayBag::ArrayBag(): itemCount(0), maxItems(DEFAULT_CAPACITY)

{

}

template

int ArrayBag::getCurrentSize() const

{

       return itemCount;

}

template

bool ArrayBag::isEmpty() const

{

       return itemCount == 0;

}

template

bool ArrayBag::add(const ItemType& newEntry)

{

       bool hasRoomToAdd = (itemCount < maxItems);

       if (hasRoomToAdd)

       {

              items[itemCount] = newEntry;

              itemCount++;

       }     

       return hasRoomToAdd;

}

template

bool ArrayBag::remove(const ItemType& anEntry)

{

   int locatedIndex = getIndexOf(anEntry);

       bool canRemoveItem = !isEmpty() && (locatedIndex > -1);

       if (canRemoveItem)

       {

              itemCount--;

              items[locatedIndex] = items[itemCount];

       }

   

       return canRemoveItem;

}

template

void ArrayBag::clear()

{

       itemCount = 0;

}

template

int ArrayBag::getFrequencyOf(const ItemType& anEntry) const

{

   int frequency = 0;

   int curIndex = 0;      

   while (curIndex < itemCount)

   {

      if (items[curIndex] == anEntry)

      {

         frequency++;

      }

     

      curIndex++;         

   }

  

   return frequency;

}

template

bool ArrayBag::contains(const ItemType& anEntry) const

{

       return getIndexOf(anEntry) > -1;

}

template

vector ArrayBag::toVector() const

{

       vector bagContents;

       for (int i = 0; i < itemCount; i++)

              bagContents.push_back(items[i]);

     

   return bagContents;

}

template

int ArrayBag::getIndexOf(const ItemType& target) const

{

       bool found = false;

   int result = -1;

   int searchIndex = 0;

  

   while (!found && (searchIndex < itemCount))

   {

      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 toVector() const = 0;

};

#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.

Explanation / Answer

Hi..

#ifndef _ARRAY_BAG
#define _ARRAY_BAG
#include "BagInterface.h"
template
class Arraybags : public BagInterface
{
private:
static const int DEFAULT_CAPACITY = 6;
ItemType items[DEFAULT_CAPACITY];   
int itemCount;
int maxItems
  
int getIndexOf(const ItemType& target) const;
public:
Arraybags();
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 toVector() const;
};
#include "Arraybags.cpp"
#endif
Arraybags.cpp
#include "Arraybags.h"
#include
template
Arraybags::Arraybags(): itemCount(0), maxItems(DEFAULT_CAPACITY)
{
}
template
int Arraybags::getCurrentSize() const
{
return itemCount;
}
template
bool Arraybags::isEmpty() const
{
return itemCount == 0;
}
template
bool Arraybags::add(const ItemType& newEntry)
{
bool hasRoomToAdd = (itemCount < maxItems);
if (hasRoomToAdd)
{
items[itemCount] = newEntry;
itemCount++;
}   
return hasRoomToAdd;
}
template
bool Arraybags::remove(const ItemType& anEntry)
{
int locatedIndex = getIndexOf(anEntry);
bool canRemoveItem = !isEmpty() && (locatedIndex > -1);
if (canRemoveItem)
{
itemCount--;
items[locatedIndex] = items[itemCount];
}

return canRemoveItem;
}
template
void Arraybags::clear()
{
itemCount = 0;
}
template
int Arraybags::getFrequencyOf(const ItemType& anEntry) const
{
int frequency = 0;
int curIndex = 0;
while (curIndex < itemCount)
{
if (items[curIndex] == anEntry)
{
frequency++;
}

curIndex++;   
}
  
return frequency;
}
template
bool Arraybags::contains(const ItemType& anEntry) const
{
return getIndexOf(anEntry) > -1;
}
template
vector Arraybags::toVector() const
{
vector bagContents;
for (int i = 0; i < itemCount; i++)
bagContents.push_back(items[i]);

return bagContents;
}
template
int Arraybags::getIndexOf(const ItemType& target) const
{
bool found = false;
int result = -1;
int searchIndex = 0;
  
while (!found && (searchIndex < itemCount))
{
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 toVector() const = 0;
};
#endif

thanks

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote