Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write And Test An Array Class [StaticArray.h and StaticArray.TestDriver.cpp] Write a data structures template. The resulting template can be used in any program in place

image text in transcribedimage text in transcribed

Write And Test An Array Class [StaticArray.h and StaticArray.TestDriver.cpp] Write a data structures template. The resulting template can be used in any program in place of a C++ array. Requirements. Develop StaticArray.h as you write StaticArray.TestDriver.cpp with class StaticArray, defined and fully tested. Write the public interface exactly as specified below -- do not add to, or change the public interface as specified. 1. Write the template for an array of values of unspecified type. 2. Let the capacity be set as part of the template specification, as modeled in the reading. 3. Include a square bracket getter and a setter, both with index range-checking, returning whatever value you wish, if out of range. 4. Include a getter named StaticArray::capacity() to return the data structure's capacity. 5. Initialize all data members to their default values in the constructor. That includes setting the array elements to their default data type. 6. Do tests with int , double, and char . Also do tests with an object, like string . Do NOT write any other functions in the public interface. StaticArray template class public interface: \begin{tabular}{l} \hline template T, int CAP> \\ class StaticArray \\ \{ value[CAP]; // T datatype CAP compasity \\ T dummy; \\ public: \\ StaticArray(); \\ int capacity() const ; \\ T operator[ ] (int) const; // getter \\ T\& operator[ ] (int); // setter \\ \}; \end{tabular} Write An Array Application [MyStaticArray.cpp] Write MyStaticArray.cpp using your StaticArray template. Use your already-tested and verified H file from part 1. Exactly as in Programming Assignment 1's MyArray.cpp, this app lets its user enter as many values as they like, and when that process is completed, lets the user look up values by matching index. Except that these values are doubles. Use a StaticArray object of capacity 100 to track the values. In a loop, the app should prompting the user to enter a pair of numbers on the same line: a whole number index and its corresponding floating point value. Do not validate input in the app, because your template should handle out-of-range indexes, and it should allow overwriting an already-entered index. Quit the loop when an uppercase or lowercase Q is entered for either the index or the value. Indexes can be entered in any order -- they don't have to start with zero and go up by one thereafter. It's whatever the user enters. Your app should keep track of which indexes got entered. Use a bool StaticArray for that. After all data entry is complete, the app should: 1. output how many (unique) indexes got entered, 2. output the list of all used indexes and their values, per the example below, and 3. implement an event-controlled loop that prompts for an index value and outputs whether the index is in use or not, and if in use, what is the value stored for that index. Loop until the user elects to stop by entering uppercase or lowercase Q. Here's a sample of how this should work (user input in blue): Input an index and a value [Q to quit]: 3312 Input an index and a value [Q to quit ]:4100 Input an index and a value [Q to quit]: 5300 Input an index and a value [Q to quit ]:x1.7 Input an index and a value [Q to quit]: 33120 Input an index and a value [Q to quit]: 123.4 Input an index and a value [Q to quit]: 2000999 Input an index and a value [Q to quit]: 499 Input an index and a value [Q to quit]: a You stored this many values: 4 The index-value pairs are: 01.7499530033120 Input an index for me to look up [Q to quit]: 33 Found it -- the value stored at 33 is 120 Input an index for me to look up [Q to quit] : 38 I didn't find it Input an index for me to look up [Q to quit]: 0 Found it -- the value stored at is 1.7 Input an index for me to look up [Q to quit] : -100 I didn't find it Input an index for me to look up [Q to quit]: 1000 I didn't find it Input an index for me to look up [Q to quit]

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

Oracle 10g SQL

Authors: Joan Casteel, Lannes Morris Murphy

1st Edition

141883629X, 9781418836290

More Books

Students also viewed these Databases questions

Question

Which companys ratios match Column G?

Answered: 1 week ago

Question

Explain the steps involved in training programmes.

Answered: 1 week ago

Question

What are the need and importance of training ?

Answered: 1 week ago