Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

C++ programming language.

Please help me complete the DynamicStringArray.cpp.

I pasted the codes that you need to complete it. Below is DynamicStringArray.h,DynamicStringArray.cpp, and the main.cpp. Please help me.

below code is DynamicStringArray.h:

//***********************************************//
// Please do not change the this file !!!!!
//***********************************************//
#ifndef DYNAMICSTRINGARRAY _H
#define DYNAMICSTRINGARRAY _H
#include <iostream>
#include <string>
using namespace std;

class DynamicStringArray
{
public:
DynamicStringArray();
int sizeIs();
string* getDynamicArray ();
void addEntry (string);
bool deleteEntry (string);
string* getEntry(int );
~DynamicStringArray ();
void printDynamicArray();

private:
string *dynamicArray;
int size;
};

#endif // DYNAMICSTRINGARRAY _H

BELOW IS MAIN.CPP

//***********************************************//
// Do not change the this main program !!!!!
//***********************************************//
#include "DynamicStringArray .h"
#include <iostream>
#include <string>
using namespace std;

int main()
{
int op;
string str;
DynamicStringArray List; //DynamicStringArray=NULL size=0
cout<<"------>>> choose an option from the menu <<<------"<<endl;

cout<<" 1.Add an entry to the list of string........"<<endl;
cout<<" 2.Delete an entry to the list of string....."<<endl;
cout<<" 3.Display the list entries.................."<<endl;
cout<<" 4.End Program..............................."<<endl;
do{
cout<<"\n >> Enter your option from the menu:";
cin>>op;
if(op<=0 || op>5) {
cout<<"Wrong choice. Try again!!"<<endl;
continue;
}
switch(op){
case 1:
cout<<" >>> Enter a string to add to the list: ";
cin>> str;
List.addEntry (str);
break;
case 2:
cout<<" >>> Enter a string to remove from the list: ";
cin>> str;
List.deleteEntry(str);
break;
case 3:
List.printDynamicArray();
break;
case 4:
break;
}

} while(op!=4);

cout<<"End of Program.Bye!";
return 0;
}

Below is the code i have to change:

// Write the implementation of every method of the class
// DynamicStringArray defined in DynamicStringArray.h

#include "DynamicStringArray .h"

//default constructor
DynamicStringArray ::DynamicStringArray (){

//write code body of DynamicStringArray ()

}

int DynamicStringArray ::sizeIs(){
//write code body of sizeIs ()
}

void DynamicStringArray ::addEntry (string str){
//write code body of addEntry ()
};

bool DynamicStringArray::deleteEntry (string str){
//write code body of deleteEntry ()
}
string* DynamicStringArray::getEntry(int index){
//write code body of deleteEntry ()
}
//destructor
DynamicStringArray ::~DynamicStringArray (){
//write code body of ~DynamicStringArray ()
}

void DynamicStringArray ::printDynamicArray(){
//write code body of printDynamicArray ()

}

[画像:One problem with dynamic arrays is that the is created once array using the new operator the size might want For example, you to add or delete entries from the array. This project asks cannot be changed. you to create a class called DynamicStringArray that includes member functions that allow it. The class should have the following private member variables dynamicArray that references a dynamic array of type string. size that holds the number of entries in the array. The class should have the following public methods: A default constructor that sets the dynamic array to NULL and sets size to 0. A function sizeIs that returns size. function named addEntry that string input. element larger А takes a as The function should create new dynamic array one a than dynamicArray, copy all elements from dynamicArray into the array, add the new string onto the end of the new new array, increment size, delete the old dynamicArray and then set dynamicArray to the new array. A function named deleteEntry that takes a string as input. The function should search dynamicArray for the string. If not found, it returns false. If found, it creates new dynamic array one should copy all delete dynamicArray , a element smaller than dynamicArray. It elements except the input string into the new array, decrement size, and return true. A function named getEntry that takes integer input and an as the string at index in dynamicArray. returns that It should return NULL if the index is out of dynamicArray's bounds. A destructor that frees up the memory allocated to the dynamic array. printDynamicArray () dynamicArray that displays the elements of the Instructions: You will be given 3 files: DynamicStringArray.h (Do not modify) DynamicStringArray.cpp (to be competed) main.cpp (Do not modify) ]
expand button
Transcribed Image Text:One problem with dynamic arrays is that the is created once array using the new operator the size might want For example, you to add or delete entries from the array. This project asks cannot be changed. you to create a class called DynamicStringArray that includes member functions that allow it. The class should have the following private member variables dynamicArray that references a dynamic array of type string. size that holds the number of entries in the array. The class should have the following public methods: A default constructor that sets the dynamic array to NULL and sets size to 0. A function sizeIs that returns size. function named addEntry that string input. element larger А takes a as The function should create new dynamic array one a than dynamicArray, copy all elements from dynamicArray into the array, add the new string onto the end of the new new array, increment size, delete the old dynamicArray and then set dynamicArray to the new array. A function named deleteEntry that takes a string as input. The function should search dynamicArray for the string. If not found, it returns false. If found, it creates new dynamic array one should copy all delete dynamicArray , a element smaller than dynamicArray. It elements except the input string into the new array, decrement size, and return true. A function named getEntry that takes integer input and an as the string at index in dynamicArray. returns that It should return NULL if the index is out of dynamicArray's bounds. A destructor that frees up the memory allocated to the dynamic array. printDynamicArray () dynamicArray that displays the elements of the Instructions: You will be given 3 files: DynamicStringArray.h (Do not modify) DynamicStringArray.cpp (to be competed) main.cpp (Do not modify)
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
    Recommended textbooks for you
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education