subject

The function retrieveAt of the class arrayListType is written as a void function. Rewrite this function so that it is written as a value returning function, returning the required item. If the location of the item to be returned is out of range, use the assert function to terminate the program. Also, write a program to test your function. Use the class unorderedArrayListType to test your function. we have arrayListType. h
#ifndef H_arrayListType
#define H_arrayListType
#include
#include
class arrayListType {
public:
bool isFull() const;
int listSize() const;
int maxListSize() const;
void print() const;
bool isItemAtEqual(int location, int item) const;
virtual void insertAt(int location, int insertItem) = 0;
virtual void insertEnd(int insertItem) = 0;
void removeAt(int location);
// void retrieveAt(int location, int& retItem) const;
int retrieveAt(int location, array){
if(location <= array. size() - 1){
return array[location]; } else{
cout<<"Location out of range";
assert(); // Assuming the assert function is defined in the program. }}
int arrayListType::retrieveAt(int location) const{
int retItem = 0;
assert( (location < 0) || (location >= length));
retItem = list[location];
return retItem;} //end retrieveAt*/
//int retrieveAt(int location) const;
virtual void replaceAt(int location, int repItem) = 0;
void clearList();
virtual int seqSearch(int searchItem) const = 0;
virtual void remove(int removeItem) = 0;
arrayListType (const arrayListType& otherList);
virtual ~arrayListType();
protected:
int *list; //array to hold the list elements
int length; //variable to store the length of the list
int maxSize; //variable to store the maximum
//size of the list
}; #endif
arrayListTypeImp. cpp

#include
#include
#include "arrayListType. h"
using namespace std;
bool arrayListType::isEmpty() const{
return (length == 0);
} //end isEmpty
bool arrayListType::isFull() const{
return (length == maxSize);
} //end isFull
int arrayListType::listSize() const{
return length;
} //end listSize
int arrayListType::maxListSize() const{
return maxSize;
} //end maxListSize
void arrayListType::print() const{
for (int i = 0; i < length; i++)
cout << list[i] << " ";
cout << endl;
} //end print
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);
} //end isItemAtEqual
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];
length--;
}
} //end removeAt
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];
} //end retrieveAt
void arrayListType::clearList(){
length = 0;
} //end clearList
arrayListType::arrayListType(int size){
if (size <= 0; {
cout << "The array size must be positive. Creating "
<< "an array of the size 100." << endl;
maxSize = 100;}
else
maxSize = size;
length = 0;
list = new int[maxSize];
} //end constructor
arrayListType::~arrayListType(){
delete [] list;
} //end destructor
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];
}//end copy constructor

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 24.06.2019 09:10
  to change the number of rows and columns displayed by the excel object a. select the object and drag a size handle on the active object. b. deselect the object and drag a size handle of the object. c. deselect the object and drag a row or column divider of the object. d. select the object and drag a row or column divider on the active object.
Answers: 2
question
Computers and Technology, 24.06.2019 20:20
Write python code that prompts the user to enter his or her favorite color and assigns the user’s input to a variable named color.
Answers: 1
question
Computers and Technology, 24.06.2019 20:30
How is energy expended in active transport
Answers: 1
question
Computers and Technology, 25.06.2019 15:30
In a paragraph of no less than 125 words, explain what netiquette is and how it improves efficiency and productivity in the workplace.
Answers: 1
You know the right answer?
The function retrieveAt of the class arrayListType is written as a void function. Rewrite this funct...
Questions
question
Mathematics, 19.07.2019 12:50