This Array implementation allows duplicates.
Add a method that searches the array and remove all the valuesin the array that does not have a duplicate.
void removeNoDups( ) ( 12 points)
For example if array had elements 100 200 100 100 200 400 500300, once this new method is run it should return 100 200 100 100200 removing 400, 500 and 300 which do not have duplicate values inthe array. So in short this method allows only values withduplicates.
Add a main file to test your implementation of thefunction( 3 points )
#include
using namespace std;
class CSIS3400Arrays
{
private:
int size;
int numberOfElements = 0;
int* intArray;
/*locating method for the array*/
int locationOf(int target);
public:
//default constructor and constructor
CSIS3400Arrays();
CSIS3400Arrays(int BUFFER_SIZE);
//destructor
~CSIS3400Arrays();
/*standard array methods*/
bool insert(int value);
bool remove(int value);
bool find(int target);
void display();
};
#include \"Midterm3400Arrays.h\"
//default constructor
CSIS3400Arrays::CSIS3400Arrays()
{
size = 100;
intArray = new int[size];
}
// constructor
CSIS3400Arrays::CSIS3400Arrays(int bufSize)
{
size = bufSize;
intArray = new int[size];
}
//destructor
CSIS3400Arrays::~CSIS3400Arrays()
{
if (intArray)
{
delete[] intArray;
}
}
/*locating target in the array*/
int CSIS3400Arrays::locationOf(int target)
{
/* finds the target index if exists then returns that index*/
for (int i = 0; i < numberOfElements; i++)
if (intArray[i] == target)
{
return i;
}
/*returns -1 if not located*/
return -1;
}
/*inserts value into the array*/
bool CSIS3400Arrays::insert(int value)
{
/*checks to see if array is full*/
if (numberOfElements < size)
{
/* adds the value into the next empty slot*/
intArray[numberOfElements++] = value;
return true;
}
else
{
/*prints that array is full*/
cout << \"\nArray is Full and insert failed\n\" <<\"\n\";
return false;
}
}
/*removes the value and then shifts up the values to fill in theempty spot(s)*/
bool CSIS3400Arrays::remove(int value)
{
int index = locationOf(value);
if (index != -1)
{
cout << \"\nInteger: \" << intArray[locationOf(value)]<< \" removed\n\n\";
for (int i = index; i < numberOfElements - 1; i++)
{
intArray[i] = intArray[i + 1];
}
numberOfElements--;
return true;
}
else
{
cout << \"\nValue not found in array\n\" <<\"\n\";
return false;
}
}
/*returns whether a value is found or not found in thearray*/
bool CSIS3400Arrays::find(int target)
{
if (locationOf(target) != -1)
{
cout << target << \" Found\n\n\";
return true;
}
else
{
cout << target << \" Not Found\n\n\";
return false;
}
}
/*prints out all the integers in the array*/
void CSIS3400Arrays::display()
{
cout << \"\nCSIS3400Arrays : \";
for (int i = 0; i < numberOfElements; i++)
{
if (i == numberOfElements - 1)
{
cout << intArray[i];
}
else
{
cout << intArray[i] << \",\";
}
}
cout << endl;
}