Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

implement the LinkedList ADT [the declaration is given in ListLinked.h] - implement the following operations: - remove, replace, clear; (30 pts) - isFull, isEmpty; (10

implement the LinkedList ADT [the declaration is given in ListLinked.h]

- implement the following operations:

- remove, replace, clear; (30 pts)

- isFull, isEmpty; (10 pts)

- gotoBeginning, gotoEnd, gotoNext, gotoPrior, getCursor; (20 pts)

HERE IS THE GIVEN CODE:

ListLinked.h:

//--------------------------------------------------------------------

//

// Laboratory 5 ListLinked.h

//

// Class declaration for the linked implementation of the List ADT

//

//--------------------------------------------------------------------

#ifndef LISTLINKED_H

#define LISTLINKED_H

#include

#include

using namespace std;

template

class List {

public:

List(int ignored = 0);

List(const List& other);

List& operator=(const List& other);

~List();

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::ListNode::ListNode(const DataType& nodeData, ListNode*

nextPtr)

{

this->dataItem = nodeData;

this->next = nextPtr;

}

// List member functions

template

List::List(int ignored = 0)

{

}

template

List::List(const List& other)

{

}

template

List& List::operator=(const List& other)

{

}

template

List::~List()

{

}

template

void List::insert(const DataType& newDataItem) throw

(logic_error)

{

}

template

void List::remove() throw (logic_error)

{

}

template

void List::replace(const DataType& newDataItem) throw

(logic_error)

{

}

template

void List::clear()

{

}

template

bool List::isEmpty() const

{

return false;

}

template

bool List::isFull() const

{

return false;

}

template

void List::gotoBeginning() throw (logic_error)

{

}

template

void List::gotoEnd() throw (logic_error)

{

}

template

bool List::gotoNext() throw (logic_error)

{

return false;

}

template

bool List::gotoPrior() throw (logic_error)

{

return false;

}

template

DataType List::getCursor() const throw (logic_error)

{

DataType t;

return t;

}

template

void List::moveToBeginning () throw (logic_error)

{

}

template

void List::insertBefore(const DataType& newDataItem) throw

(logic_error)

{

}

#include "show5.cpp"

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

Students also viewed these Databases questions