Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answwr this in C++ with detail. I will upvote you are greatly appreciated. Task: You are to implement the list abstract data type using

please answwr this in C++ with detail. I will upvote you are greatly appreciated.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Task: You are to implement the list abstract data type using an array data structure. Your underlying array will have 50 maximum elements (set using a constant set with a \#define with the name MAXELEMENTS). The list abstract data type operates in a similar way to the way that we use lists in our personal life. You start a list by adding (appending) items to it. At any time, your eyes are focusing on a current item. You might remove that item - making the next item your new current item. or insert an item ahead of that item - making the newly added item your new current item. In the list ADT, you will navigate by moving to either the next item or the previous - making that the new current item. You should have a class ArrayList when finished. This class should include the following member methods: You will be completing the class definition and supplying the member methods. The main 0 is provided and will remain unchanged. The main accepts a number from the console input field that corresponds to one of four testbenches. They are: - 0=easier (appending and movement) - 1 amedium (movement and removing in the middle of the tist) - 2=harder (appending excess elements and removing at the ends of the list) - 3*Full testbench If you attempt to append or insert beyond the limits of the array or attempt to remove an element from an empty list, you should see the appropriate error message shown: Append failed. List full. Insert failed. List full. Remove failed. List empty. CurrValue failed. List empty. As with all programming projects, you should should have formal code that is properly commented and include headers. Your comments will be evaluated after your code is submitted and are worth 20 points. The following multipliers will be applied: - Proper Comments: 20 points - Minimal Comments 10 points - No Comments 0 points Note: the main() program provided requires input from the console. Put in a 0, 1, 2, or 3 into the "Enter program input (optional)" box when in develop mode. \#include using namespace std; \#include "Arraylist.h" void easytest(Arraylist *testlist); void meditest (Arraylist *testList); void hardtest(Arraylist "testlist); void ice_test (Arraylist "testlist); / main. cpp program: date: 02/17/2021 description: this main () tests a list data type. the user is prompted for one of four testbenches. the list is to have a maximum of 50 elements. 11 notes: there is no prompting of the user. this file is not to be edited. 11 II int main() f Arraylist - myList = new Arraylist(); // instantiate list object int x6; /l user choice variable cin >xi Il accept user choice if (x0) easytest(myList); // easier test with 10 elements if (x=1) meditest(myList); I medium test with 30 elements if (x=2) hardtest (myList); I/ harder test with 50 elements if (x3) ice_test(myList); I testbench matching LList ICE return 0 ; 3 II 5 / function: easytest (Alist "test L ist) II function: hardtest (Arraylist "testlist) II purpose: performs high impact testing on a list object of length MAXELEMENTS (50) Il ************************************************************************************************* / void hardtest (Arraylist *testlist) \{ for(int i=1;iappend(i); I/ with four additional appends() that will fail for (int i=1;i MAXELEMENTS +2;i++ ) testList->next );/1 try to advance curr beyond end cout testlist->currValue() endl; I/ print element pointed to by curr (50) testlist remove(); /1 remove current element (50 removed) testlist->print(); cout testList->currValue() endl; / print element pointed to by curr (49) testlist prev(); (l change curr to point to the previous element (48) testlist->prev(); / change curr to point to the previous element (47) cout testlist->currValue() endl; I/ print element pointed to by curr (47) testlist-removeO); (I remove current element (47 removed) cout testlist currvalue() endl; / print element pointed to by curr (48) testlist->print(); / print list (1-49 with 47 missing) for(int i=1;i ciprrValue() endl; I/ print element pointed to by curr (1) testlist-remove(); II remove current element (1) cout testList currValue ) endl; ( print element pointed to by curr (2) testList->print(); // print list (2-49 with 47 missing) return; 121 II ********************************************************************************************** / / \#ifndef ARRAY_LIST_H \#define ARRAY_LIST_H \#define MAXELEMENTS 50 //listmaxlength=50 II Arraylist class Il List abstract data type implemented with array data structure class Arraylist \{ private: Il your member variables go here. It is suggested that you have variables for the array data, Il the current size, and the index of the current element public: Arraylist (); / (default constructor 3 Current file: Arraylist:cpp - Load default templote. 1 \#include \#include using namespace std; \#include "Arraylist.h" //Arraylist. Cpp 1/ lleach member function declared in Arraylist. h should be defined here. An example is given below 1/ insert( ) member function 1 inserts new element before current element void Arraylist: :insert(int x ) \{ llyour solution goes here

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

Current Attempt in Progress Determine the missing items

Answered: 1 week ago

Question

=+What do you wish you had known when you were starting out?

Answered: 1 week ago