Question: PROJECT: OOP static array based class Part 1: Build a class listType based on static array. Its declaration is provided below (and in shell code

PROJECT: OOP static array based class

Part 1: Build a class listType based on static array. Its declaration is provided below (and in shell code provided with this HW):

const int MAX = 100; // max # of spots of a list

class listType

{

public:

listType(int max = 5); // constructor

// Post: maxSize MAX, MAX will be used

// size

int getSize() const { return size; } // return # of elements actually stored

int getMaxSize() const { return maxSize; } // return capacity

bool isEmpty() const { return size == 0; }

bool isFull() const { return size == maxSize; }

int search(int element) const; // look for an item. return index of first occurrence

int at(int index) const; // return element at a specific location

void print() const; // print content of list on screen in format of [a, b, c] (like what ArrayList in Java does)

bool insert(int element); // append/insert an element at the end

bool insert(int index, int element); // insert an element into location index

bool remove(int index); // remove element at the specified location

private:

int dataArr[MAX]; // static array storing data items

int size; // actual # of elements stored. size

int maxSize; // 0

};

Note that the definition of four of the member functions are already provided as inline functions. You should not modify the given declaration in other unspecified ways, otherwise at least 20% penalty.

search() will return the index of the first occurrence of element if found, otherwise return -1.

Use assert() (, chapter 4, p236) to handle invalid index parameter of at(): add this line as the first statement into at(): assert(index >= 0 && index

The two insert()s and the remove() should return true when the operation is done successfully, and return false when the operation fails, such as attempt to insert into a full list, remove from an empty list, or an invalid index is provided.

Provide appropriate driver code to test this class thoroughly (dont need to test the four given functions) before proceeding to Part 2.

Part 2: modify your listType program from Part 1.

Overload binary + operator as a member to merge two listType objects: should return a listType object which contains all elements from the two operands (two listType objects). You dont need to handle duplicates or order the elements in any specific way.

Overload output operator (

remove member function print()

Modify your driver accordingly to test those two operators. Here is the output of my sample driver:

PROJECT: OOP static array based class Part 1: Build a class listType

Part 1 and Part 2: additional requirements:

Organize your program into header file (interface), implementation file, and driver file. Use #include guard with the header file.

Pre- and Post- condition comments for each function (except for the four given ones). Pre- condition may be skipped if its just xx is initialized. All parameters except for one should be IN type (either pass by value or const reference) therefore xx is initialized is implied.

Comment your program appropriately. Pay attention to the standard stuff like coding style, indention, heading, and curly braces.

list one 10. 201 Is 40 in list one? Answer -1 means no> -1 Is 10 in list one? Answer -1 means no): 0 list two [100. 1000. 20. 101 list two after remouing I01 01000. 20. 101 ?? ???[1000, 20, 10] list one after + list two10. 20. 1000 20. 101

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!