Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The program has a DNA_Strand.h. file that contains the declaration of a set of functions to manipulate static arrays representing DNA. The job is to
The program has a DNA_Strand.h. file that contains the declaration of a set of functions to manipulate static arrays representing DNA. The job is to use a test program to thoroughly test the DNA_Strand class to ensure it works as expected. The DNA_Strand.h. file describes all the public functions that need to be tested.
#ifndef DNA_STRAND_H #define DNA_STRAND_H #include//Size of static DNA Array const size_t MAX_DNA = 50; class DNA_Strand { private: // Returns true if index is within range of the current DNA_Strand bool inRange (size_t index) const; // Current size of the DNA_Strand; i.e., how many elements of the array are // currently being used (since this is a partially-filled array) size_t mySize; // DNA_Strand's storage buffer. May only be partially filled. char myDNA[MAX_DNA]; public: // Create an empty DNA_Strand. DNA_Strand (); // Create an initialized DNA_Strand. // If the string ipStr is larger than MAX_DNA(50), then only the first MAX_DNA(50) // characters of ipStr are used to initialize the DNA_Strand DNA_Strand (const std::string & ipStr); //toString //Returns string equivalent of the DNA std::string toString() const; // Set an item in the DNA_Strand at location index. Throws // <:out_of_range> if index is out of range, i.e., larger than the // current size of the DNA_Strand. // Uses zero-based indexing. void set (char new_item, size_t index); // Get an item in the DNA_Strand at location index. Throws // <:out_of_range> if index is out of range, i.e., larger than the // current size of the DNA_Strand. // Uses zero-based indexing. char get (size_t index) const; // Returns the current size of the DNA. size_t size () const; // Compare this DNA_Strand with s for equality. Returns true if the // size()'s of the two DNA_Strands are equal and all the elements from 0 // .. size()-1 are equal, else false. bool isEqual(const DNA_Strand & s) const; // search // Look for target in current DNA strand and return index. // Return -1 if not found. int search(const std::string & target) const; // search with start position specified // Look for target in current DNA strand and return index. // Return -1 if not found. If pos is past end of strand, return -1. int search(size_t pos, const std::string & target) const; }; #endif /* ifndef */
Sample tests:
#includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started