Pleae help me with this C++ task to the required result by edit or fixing, ill upvote thanks.
Unordered Sets |As explained in this chapter, a set is a collection of distinct elements of the same
type. Design the class unorderedSetType, derived from the class unorderedArrayListType, to
manipulate sets.
Note that you need to redefine only the functions insertAt, insertEnd, and replaceAt. If the item
to be inserted is already in the list, the functions insertAt and insertEnd output an appropriate
message, such as 13 is already in the set. Similarly, if the item to be replaced is already in the
list, the function replaceAt outputs an appropriate message. Also, write a program to test your
class.
main.cpp
//////////////////
unorderedArrayListTypeImp.cpp
#include
#include "unorderedArrayListType.h"
using namespace std;
void unorderedArrayListType::insertAt(int location,
int insertItem) {
if (location < 0 || location >= maxSize)
cout << "The position of the item to be inserted "
<< "is out of range." << endl;
else if (length >= maxSize) //list is full
cout << "Cannot insert in a full list" << endl;
else {
for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at
//the specified position
length++; //increment the length
}
} //end insertAt
void unorderedArrayListType::insertEnd(int insertItem) {
if (length >= maxSize) //the list is full
cout << "Cannot insert in a full list." << endl;
else {
list[length] = insertItem;
length++;
}
} //end insertEnd
int unorderedArrayListType::seqSearch(int searchItem) const {
int loc;
bool found = false;
loc = 0;
while (loc < length && !found)
if (list[loc] == searchItem)
found = true;
else
loc++;
if (found)
return loc;
else
return -1;
} //end seqSearch
void unorderedArrayListType::remove(int removeItem) {
int loc;
if (length == 0)
cout << "Cannot delete from an empty list." << endl;
else {
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
else
cout << "The item to be deleted is not in the list."
<< endl;
}
}
void unorderedArrayListType::removeAll(int removeItem) {
int loc;
if (length == 0)
cout << "Cannot delete from an empty list." << endl;
else{
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
else
cout << "The item to be deleted is not in the list." << endl;
}
// Set up a loop to find other occurrences and delete them as well
while (loc != -1)
{
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
}
}
void unorderedArrayListType::replaceAt(int location, int repItem) {
if (location < 0 || location >= length)
cout << "The location of the item to be "
<< "replaced is out of range." << endl;
else
list[location] = repItem;
}
unorderedArrayListType::unorderedArrayListType(int size)
: arrayListType(size) {
}
////////////////////////
unorderedArrayListType.h
///////////////////
arrayListTypeImp.cpp
#include
#include "arrayListType.h"
using namespace std;
bool arrayListType::isEmpty() const {
return (length == 0);
}
bool.
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Pleae help me with this C++ task to the required result by edit or f.pdf
1. Pleae help me with this C++ task to the required result by edit or fixing, ill upvote thanks.
Unordered Sets |As explained in this chapter, a set is a collection of distinct elements of the same
type. Design the class unorderedSetType, derived from the class unorderedArrayListType, to
manipulate sets.
Note that you need to redefine only the functions insertAt, insertEnd, and replaceAt. If the item
to be inserted is already in the list, the functions insertAt and insertEnd output an appropriate
message, such as 13 is already in the set. Similarly, if the item to be replaced is already in the
list, the function replaceAt outputs an appropriate message. Also, write a program to test your
class.
main.cpp
//////////////////
unorderedArrayListTypeImp.cpp
#include
#include "unorderedArrayListType.h"
using namespace std;
void unorderedArrayListType::insertAt(int location,
int insertItem) {
if (location < 0 || location >= maxSize)
cout << "The position of the item to be inserted "
<< "is out of range." << endl;
else if (length >= maxSize) //list is full
cout << "Cannot insert in a full list" << endl;
else {
2. for (int i = length; i > location; i--)
list[i] = list[i - 1]; //move the elements down
list[location] = insertItem; //insert the item at
//the specified position
length++; //increment the length
}
} //end insertAt
void unorderedArrayListType::insertEnd(int insertItem) {
if (length >= maxSize) //the list is full
cout << "Cannot insert in a full list." << endl;
else {
list[length] = insertItem;
length++;
}
} //end insertEnd
int unorderedArrayListType::seqSearch(int searchItem) const {
int loc;
bool found = false;
3. loc = 0;
while (loc < length && !found)
if (list[loc] == searchItem)
found = true;
else
loc++;
if (found)
return loc;
else
return -1;
} //end seqSearch
void unorderedArrayListType::remove(int removeItem) {
int loc;
if (length == 0)
cout << "Cannot delete from an empty list." << endl;
else {
loc = seqSearch(removeItem);
if (loc != -1)
4. removeAt(loc);
else
cout << "The item to be deleted is not in the list."
<< endl;
}
}
void unorderedArrayListType::removeAll(int removeItem) {
int loc;
if (length == 0)
cout << "Cannot delete from an empty list." << endl;
else{
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
else
cout << "The item to be deleted is not in the list." << endl;
}
5. // Set up a loop to find other occurrences and delete them as well
while (loc != -1)
{
loc = seqSearch(removeItem);
if (loc != -1)
removeAt(loc);
}
}
void unorderedArrayListType::replaceAt(int location, int repItem) {
if (location < 0 || location >= length)
cout << "The location of the item to be "
<< "replaced is out of range." << endl;
else
list[location] = repItem;
}
unorderedArrayListType::unorderedArrayListType(int size)
: arrayListType(size) {
}
////////////////////////
7. cout << list[i] << " ";
cout << endl;
}
bool arrayListType::isItemAtEqual(int location, int item) const {
if (location < 0 || location >= length) {
cout << "The location of the item to be removed "
<< "is out of range." << endl;
return false;
} else
return (list[location] == item);
}
void arrayListType::removeAt(int location) {
if (location < 0 || location >= length)
cout << "The location of the item to be removed "
<< "is out of range." << endl;
else {
for (int i = location; i < length - 1; i++)
list[i] = list[i + 1];
8. length--;
}
}
void arrayListType::retrieveAt(int location, int& retItem) const {
if (location < 0 || location >= length)
cout << "The location of the item to be retrieved is "
<< "out of range" << endl;
else
retItem = list[location];
}
void arrayListType::clearList() {
length = 0;
}
arrayListType::arrayListType(int size) {
if (size <= 0) {
cout << "The array size must be positive. Creating "
<< "an array of the size 100." << endl;
maxSize = 100;
9. } else
maxSize = size;
length = 0;
list = new int[maxSize];
}
arrayListType::~arrayListType() {
delete [] list;
}
arrayListType::arrayListType(const arrayListType& otherList) {
maxSize = otherList.maxSize;
length = otherList.length;
list = new int[maxSize]; //create the array
for (int j = 0; j < length; j++) //copy otherList
list[j] = otherList.list[j];
}
//////////////////////////////
arrayListType.h
////////////////
unorderedSetTypeImp.cpp
#include
10. #include "unorderedSetType.h"
using namespace std;
unorderedSetType::unorderedSetType(int size):unorderedArrayListType(size) {
}
void unorderedSetType::insertAt(int location, int insertItem) {
if(!isEmpty()) {
if(seqSearch(insertItem)!=-1) {
cout<<"The entered item is already present in the list set!."<