Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++, with instructions, please .. I need to understand Create your own Collection Class that will store values in an array of type double.

In C++, with instructions, please .. I need to understand

image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions

Question

7. Where Do We Begin?

Answered: 1 week ago