Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The files taht are important to the question in the photo are, abstract _ bag.hpp #ifndef _ ABSTRACT _ BAG _ HPP _ #define _
The files taht are important to the question in the photo are,
abstractbag.hpp
#ifndef ABSTRACTBAGHPP
#define ABSTRACTBAGHPP
#include
edit
#endif
bagsimple.hpp
#ifndef STUDENTBAGHPP
#define STUDENTBAGHPP
#include "abstractbag.hpp
template class Bag
public:
Bag;
~Bag;
std::sizet getCurrentSize const;
bool isEmpty const;
bool addconst T& entry;
bool removeconst T& entry;
void clear;
std::sizet getFrequencyOfconst T& entry const;
bool containsconst T& entry const;
static const std::sizet MAXSIZE ;
private:
implementation using fixed automatic storage
std::sizet size;
T dataMAXSIZE;
;
#include "bagsimple.tpp
#endif
bagsimple.tpp
#include "bagsimple.hpp
#include
implementation using fixed automatic storage
template Bag::Bag: size
template Bag::~Bag
template std::sizet Bag::getCurrentSize const return size;
template bool Bag::isEmpty const return size ;
template bool Bag::addconst T& entry
ifsize MAXSIZE
return false;
datasize entry;
size;
return true;
template bool Bag::removeconst T& entry
ifsize return false;
std::sizet idx ;
forstd::sizet i ; i size; i
ifdatai entry break;
idx;
ifidx size return false;
size;
forstd::sizet i idx; i size; i
datai datai;
return true;
template void Bag::clear size ;
template std::sizet Bag::getFrequencyOfconst T& entry const
std::sizet freq ;
forstd::sizet i ; i size; i
ifdatai entryfreq;
return freq;
template bool Bag::containsconst T& entry const
return getFrequencyOfentry;
bagtest.cpp
#define CATCHCONFIGMAIN
#include "catch.hpp
#include "bagsimple.hpp
force template expansion
template class Bag;
TESTCASETest Type", Bag
REQUIREstd::isbaseof AbstractBag,Bag ::value;
TESTCASETest ConstructionDestructionBag
Bag b;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
TESTCASETest add", Bag
Bag b;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
forint i ; i Bag::MAXSIZE; i
REQUIREbaddi;
REQUIREbgetCurrentSize i;
REQUIREbisEmpty;
REQUIREbadd;
TESTCASETest remove", Bag
Bag b;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
forint i ; i Bag::MAXSIZE; i
REQUIREbaddi;
REQUIREbgetCurrentSize i;
REQUIREbisEmpty;
REQUIREbremove;
forint i ; i Bag::MAXSIZE; i
REQUIREbremovei;
REQUIREbremove;
TESTCASETest clear", Bag
Bag b;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
bclear;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
forint i ; i Bag::MAXSIZE; i
REQUIREbaddi;
REQUIREbgetCurrentSize i;
REQUIREbisEmpty;
bclear;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
TESTCASETest frequency", Bag
Bag b;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
REQUIREbgetFrequencyOf;
forint i ; i Bag::MAXSIZE; i
REQUIREbaddi;
REQUIREbgetCurrentSize i;
REQUIREbisEmpty;
forint i ; i Bag::MAXSIZE; i
REQUIREbgetFrequencyOfi;
Bag b;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
forint i ; i Bag::MAXSIZE; i
REQUIREbadd;
REQUIREbgetCurrentSize i;
REQUIREbisEmpty;
std::sizet EXPECTED Bag::MAXSIZE;
REQUIREbgetFrequencyOf EXPECTED;
REQUIREbgetFrequencyOf;
TESTCASETest contains", Bag
Bag b;
REQUIREbgetCurrentSize;
REQUIREbisEmpty;
REQUIREbcontains;
forint i ; i Bag::MAXSIZE; i
REQUIREbaddi;
REQUIREbgetCurrentSize i;
REQUIREbisEmpty;
forint i ; i Bag::MAXSIZE; i
REQUIREbcontainsi;
REQUIREbcontains;
Bag b;
REQUIREbgetCurrentSize;
RE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started