Question: In C++, using the following code: #include #include #include Collection.h using namespace std; void TestCollection(); void TestExceedSize(); void TestAddBeginning(); void TestExtractionOperator(); bool checkCase(std::string name, bool

 In C++, using the following code: #include #include #include "Collection.h" using

In C++, using the following code:

#include #include #include "Collection.h"

using namespace std;

void TestCollection(); void TestExceedSize(); void TestAddBeginning(); void TestExtractionOperator(); bool checkCase(std::string name, bool condition);

int main() { TestCollection(); TestExceedSize(); TestAddBeginning(); TestExtractionOperator(); return 0; } void TestCollection(){ Collection one; one.add(2.2); one.add(4.5);

checkCase("Adding 1", one.get(0) == 2.2); checkCase("Adding 2", one.get(1) == 4.5); checkCase("Check Size", one.getSize()== 2); } void TestExceedSize(){ Collection one; for(int i = 0; i

checkCase("Exceed Size 1", one.get(0) == 0); checkCase("Exceed Size 2", one.get(one.getCapacity()-1) == one.getCapacity()-1);

} void TestAddBeginning(){ Collection one;

for(double i = 0; i

} void TestExtractionOperator(){ Collection one; one.add(1); one.add(2); stringstream sout; sout

bool checkCase(string name, bool condition){ if(!condition){ cout Create your own Collection Class that will store values in an array of type double. The Collection class will be able to add items to an array. Add the following methods to make it functional: . Collection(): Default constructor for the collection. Initializes the array to a fixed size of your choice Collection(int size): argument constructor that takes an integer parameter and uses it to set the initial capacity of the array . int getSize(): returns the number of elements in the array. Unlike c-strings where we had a null-terminator to mark the end of the array, in this case you will need a variable to keep track of the number of elements currently in the array. int getCapacity(); returns the maximum number of elements allowed in the current array. void add(double value) As you add the value to the back of the array, you should also check update the size (i.e. the number of elements in the array). If the new item exceeds the max size of the list, throw a runtime error... . throw runtime_error("List Full"); . void addFront(double value): This will add an item to the front of the list. If the new item exceeds the max size, throw a runtime_exception. double get(int ndx): Gets the value stored at the specified position. Throws and out_of_range exception if the index is outside the bounds of the array. double getFront(): Returns the first value in the array. Throws an out_of_range exception if the array is empty. double getEnd(): Returns the last value in the array. Throws and out_of_range exception if the array is empty. int find(double needle): returns the position of needle in the list, - 1 if not found friend std::ostream& operator

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!