Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, using the below 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 below code::

image text in transcribed

#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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Explain the necessity of critical thinking in the research process.

Answered: 1 week ago

Question

What events could trigger a change in a VIEs primary beneficiary?

Answered: 1 week ago

Question

2. Record these without judgments, criticisms, or comments.

Answered: 1 week ago

Question

Azure Analytics is a suite made up of which three tools?

Answered: 1 week ago

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago