Question: C + + ! I need you help to Write down the missing code and test it with attached cases? using namespace std; #include #includellist.h
C I need you help to Write down the missing code and test it with attached cases?
using namespace std;
#include
#include"llist.h
llist::llist
cout in llist constructor..." endl;
llist::~llist
cout in llist destructor..." endl;
PURPOSE:
PARAMETER:
bool llist::isEmpty
be sure to check all data members
PURPOSE:
PARAMETER:
void llist::displayAll
be sure to display horizontally in with
blanks between elements eg
You MUST use while P NULL loop or you will not get the credit!
PURPOSE:
PARAMETER:
void llist::addRearelt NewNum
comment the cases
PURPOSE:
PARAMETER:
void llist::addFrontelt NewNum
comment the cases
PURPOSE:
PARAMETER:
void llist::deleteFrontelt& OldNum
comment the cases
PURPOSE:
PARAMETER:
void llist::deleteRearelt& OldNum
comment the cases
Utility Function to move a local pointer to the Jth node
void llist::moveToint J Node& temp
Note that case client does not test this. But it is neede
for case so make it work perfectly.
moves temp J times to go to the Jth node and Count is assumed
for int K temp tempNext;
harder ones for case and follow
PURPOSE:
PARAMETER:
void llist::deleteIthint I, elt& OldNum
must use moveTo to move local pointers. Be sure to comment to which node you are moving them. Do not forget to set OldNum.
PURPOSE:
PARAMETER:
void llist::insertIthint I, elt newNum
must use moveTo to move local pointers. Be sure to comment to which node you are moving them.
PURPOSE:
PARAMETER:
llist::llistconst llist& Original
use my code below
PURPOSE: This is the copy constructor which copies a list into another.
PARAMETER: Original it the variable used to pass the list to be copied.
llist::llistconst llist& Original
use my code
Front NULL; Rear NULL; Count ;
this object has to be built up by allocating new cells withOtherOne elements
Node P; local pointer for OtherOne
P Original.Front;
while P NULL a loop which repeats until you reach the end of OtherOne.
thisaddRearPElem; Ps element is added to this
P PNext; Go to the next node in OtherOne
return this; return the result unconditionally. Note that the result is returned by reference.
end of if
PURPOSE:
PARAMETER:
llist& llist::operatorconst llist& OtherOne
elt x;
First make sure this and OtherOne are not the same object.
To do this, compare the pointers to the objects
if &OtherOne this if not the same
this object has to be emptied first.
while thisisEmpty
thisdeleteRearx;
this object has to be built up by allocating new cells with OtherOne elements
Node P; local pointer for OtherOne
P OtherOne.Front;
while P NULL a loop which repeats until you reach the end of OtherOne.
thisaddRearPelem; Ps element is added to this
P PNext; Go to the next node in OtherOne
end of if
return this;
use my code above
check empty and report the result
display the list
LdisplayAll;
add integers to rear
LaddRear; LaddRear; LaddRear; LaddRear
display the list
LdisplayAll;
remove from front twice and display the elements as they are removed
display the list
check empty again and report the result
remove from the rear twice display the elements removed
check empty again and report the result
add to front times elements
display the list
remove from the rear times display the elements removed
display the list again
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
