Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How to do this C++ program? (Please describe what you do, so I can understand) Create your own Collection Class that will store values in

How to do this C++ program? (Please describe what you do, so I can 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

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

Why are ratios and trends used in financial analysis?

Answered: 1 week ago

Question

How would you rate yourself against these criteria?

Answered: 1 week ago