Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The main goal of this coding project is to practice on and then fully grasp the following knowledge points in the context of ADT implementation:

The main goal of this coding project is to practice on and then fully grasp the following knowledge points in the context of ADT implementation: (This project will be graded for a total of 80 points.)

use separate files to separate a class's declaration from its implementation

fully understand the necessity of including the big-3 member functions if a class includes a pointer-based dynamic data structure

learn to implement the big-3

learn to overload different operators

learn to implement read-only accessors and mutators for a class

learn to manipulate a singly linked list at both the node-level and list-level

This project will include the following five files:

VectorADT.h: declare a class VectorADT to manage a dynamic array of doubles

VectorADT.cpp: implement VectorADT's member and non-member functions as declared in VectorADT.h

ListADT.h: declare a class ListADT to manage a linked list of integers

ListADT.cpp: implement ListADT's member and non-member functions as declared in ListADT.h

testVectorList.cpp: test the above member and non-member functions.

1. VectorADT.h

Declare a class of the name VectorADT to manage a dynamic array of doubles. Specifically, include the following data members:

double * array; int size; //the number of doubles stored in array int capacity; //the maximum number of doubles that can be stored in array 

The definition of size and capacity are similar to those used in the vector STL. Refer to this page for more information about size. Refer to this page for more information about capacity .

The interface (i.e., the public section) of VectorADT is required to include the following functions:

a default constructor to initialize the data members as follows: 0-->size, 10->capacity, and allocating a space of 10 doubles to array (of course). Don't forget to initialize each element on array to 0.00.

the "big-3": destructor, copy constructor and overloaded assignment operator

void push_back(double val ); This member function inserts the value 'val' to the end of the dynamic array

void resize(int newSize); This member function Resizes the container so that it contains newSize elements. If newSize is smaller than the current container size, the content is reduced to its first newSize elements. You don't have to reduce the capacity in this case. If newSize is greater than the current container size, the content is expanded by inserting at the end as many elements as needed to reach a size of newSize. You are required to initialize all the new elements to 0.00. If newSize is also greater than the current container capacity, make sure you increase the capacity to 2*newSize, i.e., double the value of newSize. For example, if the current value of capacity is 100 and newSize is 150, your program is going to reallocate memory to increase the capacity of arrayto 300.

void pop_back(); This member function deletes the last number from the array, i.e., it decreases the size of the container by 1.

Overload the operator[ ] as a read-only member function to return the i-th element in array. Assume v1 is a VectorADT object, this operator allows one to retrieve the i-th element on array if i is valid using the statement v1[ i ];.

Overload the addition operator (operator+) as a member function to add two VectorADT objects, say v1 and v2 if they are of the same size. This member function is not allowed to change either of its two operands. It returns a VectorADT object corresponding to the sum of v1 and v2. With this operator, one can add v1 and v2 as follows: v3 = v1+v2;

Overload the put operator (i.e., operator<<) as a friend function to print out all the elements stored in a VectorADT object. For example, assume the VectorADT object v1 contains the following numbers 1.10, 21.12, -0.81. One can write cout<

int length() const; This read-only member function returns the current size of the array (i.e., the number of doubles in the container).

int curr_capacity() const; This read-only member function returns the current capacity of the array (i.e., the maximum number of doubles that can be stored in the container).

2. VectorADT.cpp

This program file implements the above list of functions declared in VectorADT.h

3. ListADT.h

Declare a class of the name ListADT to manage a singly linked list of integers. Specifically, include the following data members:

class Node { public: Node(){ }; //implement this default constructor as an inline function using an initialization section. 0->value, nullptr->next Node(int val) { } ; //implement this constructor as an inline function using an initialization section. val->value, nullptr->next int value; Node *next }; Node *head; //point to the first node on the linked list int size; //number of nodes on the linked list 

` The interface of ListADT is required to include the following functions:

a default constructor to initialize the linked list: 0->size, nullptr->head

the "big-3": destructor, copy constructor and overloaded assignment operator

void push_back(int val ); This member function inserts the value 'val' to the end of the linked list.

void push_front(int val); This member function inserts the value 'val' to the front of the linked list.

void pop_back(); This member function deletes the last number from the linked list.

void pop_front(); This member function deletes the first number from the linked list.

Overload the operator[ ] as a read-only member function to return the i-th element on the linked list. Assume list1 is a ListADTobject, this operator allows one to retrieve the i-th element on the list if i is valid using the statement list1[ i ];. Note that this operator is not included in the STL list. We include it here to showcase how flexible operator overloading can be.

an overloaded put operator (i.e., operator<<) as a friend to print out all the data items on the linked list as a comma-separated list. For example, if a list l1 contains the following list of numbers 2->4->-1->10. The statement cout<

int length() const; This read-only member function returns the current size of the list container (i.e., the number of integers in the container).

4. ListADT.cpp

This program file implements the above list of functions declared in ListrADT.h

5. testVectorList.cpp:

Include the main() function in this program file to test all the functions you have implemented in this project.

The IDE is "Barebones" meaning it doesnt have the complex libs and shortcuts most compilers have. Code froms cratch rather then calling outside libs for everything. If not then psuedocode is also appreciated.

thank you

wrtiten in C++

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application And Administration

Authors: Michael Mannino, Michael V. Mannino

2nd Edition

0072880678, 9780072880670

More Books

Students also viewed these Databases questions