Question: #include #include #include #include #include #include using namespace std; class List{ private: int *array; int maxSize; int endOfArray; public: List(){} List(int size){ maxSize = size;

 #include #include #include #include #include #include using namespace std; class List{

#include #include #include #include #include #include

using namespace std;

class List{

private: int *array; int maxSize; int endOfArray; public: List(){} List(int size){ maxSize = size; array = new int[maxSize]; endOfArray = -1; }

void SetUp(int size){ maxSize = size; array = new int[maxSize]; endOfArray = -1; } bool isEmpty(){ if (endOfArray == -1) return true; return false; } void resize(int s){ int *tempArray = array; array = new int[s]; for (int index = 0; index

void insertAtIndex(int insertIndex, int data){ // if the user enters an invalid insertIndex, the element is // appended to the array, after the current last element if (insertIndex > endOfArray+1 || insertIndex = insertIndex; index--) array[index+1] = array[index]; array[insertIndex] = data; endOfArray++; } void deleteList(){ delete[] array; } void PrintList(){ for (int index = 0; index

int main(){

using namespace std::chrono; srand(time(NULL));

int numLists; cout > numLists; int listSize; cout > listSize; int maxValue; cout > maxValue;

// Create an array of numLists, each of size listSize // Setup/Initialize the member variables of each of the List objects in the array // Populate each List object of the array with values ranging from 1 to maxValue // Every time an integer is to be inserted to a List object, the integer is inserted // at index 0 of the List object. // Print the contents of each List object

// Delete all the List objects and clear the space allocated for the array of List // objects

system("pause"); return 0; }

In this assignment, you are provided the code for a List class that has the functions to setup/initialize the list, insert to the list, delete from the list and etc. Your task is to extend the main function of the code to create an array of List objects and insert elements (randomly generated integers) to each of these List objects and print the contents of the List objects. The base address of the array of List objects is stored in a pointer named 'listArray' of type List. The number of List objects (identified using the variable 'numLists') to be stored in the array is 5. The number of integer elements per List object (identified using the variable 'listSize') is 10. Each List object is to be filled up with randomly generated integers in the range of 1 ... max Value, where max Value = 50. Each insertion has to be made at index 0 of the List object. For example, if the random integers 23 45 12 34 49 are to be inserted to a List object, the contents of the List object after each insertion (at index 0) looks like this: 23 45 23 12 45 23 34 12 45 23 49 34 12 45 23 After filling up all the List objects, print the contents of each of them. After printing the contents of all the List objects, delete each List object and eventually clear up the space for the array of List objects

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!