Question
C++ Programming. Please make sure program compiles and ALL parts are completed for a thumbs up. Parts to be completed listed below, and I will
C++ Programming. Please make sure program compiles and ALL parts are completed for a thumbs up. Parts to be completed listed below, and I will upload all source code underneath.
config.h:
/** * Linked List class (Lab 5) configuration file. * Activate test #N by defining the corresponding LAB5_TESTN to have the value 1. */
#define LAB5_TEST1 0 // 1 means test with int instead of char #define LAB5_TEST2 0 // Activate moveToBeginning (prog exercise 2) #define LAB5_TEST3 0 // Activate insertBefore (prog exercise 3)
ListLinked.h:
//-------------------------------------------------------------------- // // Laboratory 5 ListLinked.h // // Class declaration for the linked implementation of the List ADT // //--------------------------------------------------------------------
#ifndef LISTLINKED_H #define LISTLINKED_H
#pragma warning( disable : 4290 )
#include
using namespace std;
template
void insert(const DataType& newDataItem) throw (logic_error); void remove() throw (logic_error); void replace(const DataType& newDataItem) throw (logic_error); void clear();
bool isEmpty() const; bool isFull() const;
void gotoBeginning() throw (logic_error); void gotoEnd() throw (logic_error); bool gotoNext() throw (logic_error); bool gotoPrior() throw (logic_error);
DataType getCursor() const throw (logic_error);
// Programming exercise 2 void moveToBeginning () throw (logic_error);
// Programming exercise 3 void insertBefore(const DataType& newDataItem) throw (logic_error); void showStructure() const;
private: class ListNode { public: ListNode(const DataType& nodeData, ListNode* nextPtr);
DataType dataItem; ListNode* next; };
ListNode* head; ListNode* cursor;
};
#endif
ListLinked.cpp:
#include "ListLinked.h"
// ListNode member functions
template
// List member functions
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
template
#include "show5.cpp"
show5.cpp:
//-------------------------------------------------------------------- // show5.cpp: includes implementation of showStructure //--------------------------------------------------------------------
#include "ListLinked.h"
template
// Outputs the items in a list. If the list is empty, outputs // "Empty list". This operation is intended for testing and // debugging purposes only.
{ if ( isEmpty() ) { cout next) { if (temp == cursor) { cout
// Assumes that dataItem can be printed via dataItem;
if (temp == cursor) { cout
test5.cpp:
//-------------------------------------------------------------------- // // Laboratory 5 test5.cpp // // Test program for the operations in the List ADT // //--------------------------------------------------------------------
#include
using namespace std;
void print_help();
int main() { #if LAB5_TEST1 List
print_help();
do { testList.showStructure(); // Output list
cout > cmd; if ( cmd == '+' || cmd == '=' || cmd == '#' ) cin >> testData;
switch ( cmd ) { case 'H' : case 'h': print_help(); break;
case '+' : // insert cout
case '-' : // remove cout
case '=' : // replace cout
case '@' : // getCursor cout
case '
case '>' : // gotoEnd testList.gotoEnd(); cout
case 'N' : case 'n' : // gotoNext if ( testList.gotoNext() ) cout
case 'P' : case 'p' : // gotoPrior if ( testList.gotoPrior() ) cout
case 'C' : case 'c' : // clear cout
case 'E' : case 'e' : // empty if ( testList.isEmpty() ) cout
case 'F' : case 'f' : // full if ( testList.isFull() ) cout
#if LAB5_TEST2 case 'M' : case 'm' : // In-lab Exercise 2 cout
#if LAB5_TEST3 case '#' : // In-lab Exercise 3 cout
case 'Q' : case 'q' : // Quit test program break;
default : // Invalid command cout
if( ! cin ) { // This is useful if students are testing the list with ints, instead of // chars, and accidentally enter a non-digit char. cout
return 0; }
void print_help() { cout : Go to the end of the list" implement the ListLinked ADT (the declaration is given in ListLinked.h)(60 points) implement the following operations constructor assignment operator, destructor insert, remove, replace, clear isFull, isEmpty gotoBeginning, gotoEnd, gotoNext, gotoPrior getCursor Homework exercises implement the functio m that removes the data item marked by the cursor and reinserts it at the beginning of the list (20 points implement the function insertBefore(..) that will insert the new data item before the cursor or if the list is empty as the first element of the list (20 points)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started