SlideShare a Scribd company logo
1 of 7
Implementation File:
---------------------------------------------------------
//----- List.cpp -----
#include <iostream>
using namespace std;
#include "linkedlist.h"
//-- Definition of the class constructor
List::List()
: first(0), mySize(0)
{ }
//-- Definition of the copy constructor
List::List( const List & origList)
{
mySize = origList.mySize;
first = 0;
if (mySize == 0) return ;
NodePointer origPtr, lastPtr;
first = new Node(origList.first->data); // copy first node
lastPtr = first;
origPtr = origList.first->next;
while (origPtr != 0)
{
lastPtr->next = new Node(origPtr->data);
origPtr = origPtr->next;
lastPtr = lastPtr->next;
}
}
//-- Definition of the destructor
inline List::~List()
{
NodePointer prev = first,
ptr;
while (prev != 0)
{
ptr = prev->next;
delete prev;
prev = ptr;
}
}
// Definition of empty()
bool List::empty()
{
return mySize == 0;
}
//-- Definition of the assignment operator
const List & List:: operator =( const List & rightSide)
{
mySize = rightSide.mySize;
first = 0;
if (mySize == 0) return * this ;
if ( this != &rightSide)
{
this ->~List();
NodePointer origPtr, lastPtr;
first = new Node(rightSide.first->data); // copy first node
lastPtr = first;
origPtr = rightSide.first->next;
while (origPtr != 0)
{
lastPtr->next = new Node(origPtr->data);
origPtr = origPtr->next;
lastPtr = lastPtr->next;
}
}
return * this ;
}
//-- Definition of insert()
void List::insert(ElementType dataVal, int index)
{
if (index < 0 || index > mySize)
{
cerr << "Illegal location to insert -- " << index << endl;
return ;
}
mySize++;
NodePointer newPtr = new Node(dataVal),
predPtr = first;
if (index == 0)
{
newPtr->next = first;
first = newPtr;
}
else
{
for ( int i = 1; i < index; i++)
predPtr = predPtr->next;
newPtr->next = predPtr->next;
predPtr->next = newPtr;
}
}
//-- Definition of erase()
void List::erase( int index)
{
if (index < 0 || index >= mySize)
{
cerr << "Illegal location to delete -- " << index << endl;
return ;
}
mySize--;
NodePointer ptr,
predPtr = first;
if (index == 0)
{
ptr = first;
first = ptr->next;
delete ptr;
}
else
{
for ( int i = 1; i < index; i++)
predPtr = predPtr->next;
ptr = predPtr->next;
predPtr->next = ptr->next;
delete ptr;
}
}
//-- Definition of display()
void List::display(ostream & out) const
{
NodePointer ptr = first;
while (ptr != 0)
{
out << ptr->data << " ";
ptr = ptr->next;
}
}
//-- Definition of the output operator
ostream & operator <<(ostream & out, const List & aList)
{
aList.display(out);
return out;
}
nstructions: For this lab, you will write a program that reads in a list of items for a camera store.
The items for the list are in a file called InventoryFile.txt. The program will give the user options
to insert an item, remove an item, display the list of items, search for an item, or exit the
program. Each line of the file InventoryFile has the following format: Item Number - an integer
Number in stock - an integer (between 0 and 999) Unit Price - a floating-point value Minimum
inventory level - an integer Item name a character string You will have to define a struct to hold
the info for each item, and then your list will be an array of the struets. You will probably have to
overload some operators for your struct. Your struct definition and overloaded operators should
be in a separate header/implementation file from the list header/implementation. Your driver file
should create the list, read in all the items, and then ask the user what to do (insert, delete, etc...),
repeating until the user chooses to exit When you are done, the list should be output to a file
called Newinventory. You will send me your driver, the list header and implementation, and the
struct header and implementation. InventoryFile linkedlist1 ) No Selection

More Related Content

Similar to Implementation File- -------------------------------------------------.docx

Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with PythonHan Lee
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxfaithxdunce63732
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questionsSrikanth
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3Srikanth
 
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxLab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxrennaknapp
 
C++ course start
C++ course startC++ course start
C++ course startNet3lem
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfcallawaycorb73779
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfaaseletronics2013
 
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...Yashpatel821746
 
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Yashpatel821746
 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...Yashpatel821746
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfsaradashata
 
In C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docxIn C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docxBlake0FxCampbelld
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programmingIcaii Infotech
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for ScientistsAndreas Dewes
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingMeghaj Mallick
 

Similar to Implementation File- -------------------------------------------------.docx (20)

Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
 
C aptitude questions
C aptitude questionsC aptitude questions
C aptitude questions
 
C - aptitude3
C - aptitude3C - aptitude3
C - aptitude3
 
cp05.pptx
cp05.pptxcp05.pptx
cp05.pptx
 
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docxLab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
Lab_3- Objective- Experiment with Lists- Stacks- and Queues- Simulate.docx
 
C++ course start
C++ course startC++ course start
C++ course start
 
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdfC++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
C++ problemPart 1 Recursive Print (40 pts)Please write the recu.pdf
 
Background Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdfBackground Circular Linked List A circular linked list is .pdf
Background Circular Linked List A circular linked list is .pdf
 
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
8799.pdfOr else the work is fine only. Lot to learn buddy.... Improve your ba...
 
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
Or else the work is fine only. Lot to learn buddy.... Improve your basics in ...
 
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
PYTHONOr else the work is fine only. Lot to learn buddy.... Improve your basi...
 
Grammarware Memes
Grammarware MemesGrammarware Memes
Grammarware Memes
 
C++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdfC++ Background Circular Linked List A circular linked list.pdf
C++ Background Circular Linked List A circular linked list.pdf
 
In C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docxIn C pls -- Write your name here -- Write the compiler used- Visual st.docx
In C pls -- Write your name here -- Write the compiler used- Visual st.docx
 
Assignment c programming
Assignment c programmingAssignment c programming
Assignment c programming
 
Files
FilesFiles
Files
 
Python for Scientists
Python for ScientistsPython for Scientists
Python for Scientists
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String ProcessingDynamic Objects,Pointer to function,Array & Pointer,Character String Processing
Dynamic Objects,Pointer to function,Array & Pointer,Character String Processing
 

More from RyanEAcTuckern

In 2019- Facebook announced its plan to roll out a new stablecoin call.docx
In 2019- Facebook announced its plan to roll out a new stablecoin call.docxIn 2019- Facebook announced its plan to roll out a new stablecoin call.docx
In 2019- Facebook announced its plan to roll out a new stablecoin call.docxRyanEAcTuckern
 
In 2018- Adele- who is single- acquired section 1244 stock in the init.docx
In 2018- Adele- who is single- acquired section 1244 stock in the init.docxIn 2018- Adele- who is single- acquired section 1244 stock in the init.docx
In 2018- Adele- who is single- acquired section 1244 stock in the init.docxRyanEAcTuckern
 
In 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docx
In 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docxIn 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docx
In 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docxRyanEAcTuckern
 
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docximport org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docxRyanEAcTuckern
 
import java-util-Scanner- public class MathFunctions { public static v.docx
import java-util-Scanner- public class MathFunctions { public static v.docximport java-util-Scanner- public class MathFunctions { public static v.docx
import java-util-Scanner- public class MathFunctions { public static v.docxRyanEAcTuckern
 
implement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docx
implement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docximplement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docx
implement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docxRyanEAcTuckern
 
Implements the multiplicative binomial tree numerically- Inputs- S1- u.docx
Implements the multiplicative binomial tree numerically- Inputs- S1- u.docxImplements the multiplicative binomial tree numerically- Inputs- S1- u.docx
Implements the multiplicative binomial tree numerically- Inputs- S1- u.docxRyanEAcTuckern
 
Imagine that the volcano on Mt- St- Helens erupts again- All life is.docx
Imagine that the volcano on Mt- St- Helens erupts again-  All life is.docxImagine that the volcano on Mt- St- Helens erupts again-  All life is.docx
Imagine that the volcano on Mt- St- Helens erupts again- All life is.docxRyanEAcTuckern
 
III- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docx
III- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docxIII- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docx
III- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docxRyanEAcTuckern
 
III Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docx
III Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docxIII Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docx
III Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docxRyanEAcTuckern
 
Imagine that you are planning an upcoming social media campaign for on.docx
Imagine that you are planning an upcoming social media campaign for on.docxImagine that you are planning an upcoming social media campaign for on.docx
Imagine that you are planning an upcoming social media campaign for on.docxRyanEAcTuckern
 
Iguana Incorporated paid a dividend of $1-85 this year- The dividend i.docx
Iguana Incorporated paid a dividend of $1-85 this year- The dividend i.docxIguana Incorporated paid a dividend of $1-85 this year- The dividend i.docx
Iguana Incorporated paid a dividend of $1-85 this year- The dividend i.docxRyanEAcTuckern
 
III- Assume 20 animals per group- Treatment is daily by oral gavage wi.docx
III- Assume 20 animals per group- Treatment is daily by oral gavage wi.docxIII- Assume 20 animals per group- Treatment is daily by oral gavage wi.docx
III- Assume 20 animals per group- Treatment is daily by oral gavage wi.docxRyanEAcTuckern
 
If the three subunits of a vertebrate ATP synthase are in the followi.docx
If the three  subunits of a vertebrate ATP synthase are in the followi.docxIf the three  subunits of a vertebrate ATP synthase are in the followi.docx
If the three subunits of a vertebrate ATP synthase are in the followi.docxRyanEAcTuckern
 
If the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docx
If the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docxIf the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docx
If the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docxRyanEAcTuckern
 
If Dorothy went to the prom with Daniel in early May- It was the perfe.docx
If Dorothy went to the prom with Daniel in early May- It was the perfe.docxIf Dorothy went to the prom with Daniel in early May- It was the perfe.docx
If Dorothy went to the prom with Daniel in early May- It was the perfe.docxRyanEAcTuckern
 
Identify the principal diagnosis and secondary diagnosis and place the.docx
Identify the principal diagnosis and secondary diagnosis and place the.docxIdentify the principal diagnosis and secondary diagnosis and place the.docx
Identify the principal diagnosis and secondary diagnosis and place the.docxRyanEAcTuckern
 
Identify the following formula- DMUsed Direct Labor + Allocated MOH Co.docx
Identify the following formula- DMUsed Direct Labor + Allocated MOH Co.docxIdentify the following formula- DMUsed Direct Labor + Allocated MOH Co.docx
Identify the following formula- DMUsed Direct Labor + Allocated MOH Co.docxRyanEAcTuckern
 
identify Each stage of meiosis and briefly explain what occurs during.docx
identify Each stage of meiosis and briefly explain what occurs during.docxidentify Each stage of meiosis and briefly explain what occurs during.docx
identify Each stage of meiosis and briefly explain what occurs during.docxRyanEAcTuckern
 
I- Construct a membership table for the following combination of the s.docx
I- Construct a membership table for the following combination of the s.docxI- Construct a membership table for the following combination of the s.docx
I- Construct a membership table for the following combination of the s.docxRyanEAcTuckern
 

More from RyanEAcTuckern (20)

In 2019- Facebook announced its plan to roll out a new stablecoin call.docx
In 2019- Facebook announced its plan to roll out a new stablecoin call.docxIn 2019- Facebook announced its plan to roll out a new stablecoin call.docx
In 2019- Facebook announced its plan to roll out a new stablecoin call.docx
 
In 2018- Adele- who is single- acquired section 1244 stock in the init.docx
In 2018- Adele- who is single- acquired section 1244 stock in the init.docxIn 2018- Adele- who is single- acquired section 1244 stock in the init.docx
In 2018- Adele- who is single- acquired section 1244 stock in the init.docx
 
In 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docx
In 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docxIn 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docx
In 2014- Oracle sued SAP for copyright infringement- Assume that both (1).docx
 
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docximport org-jsoup-Jsoup- import org-jsoup-nodes-Document-  import java-.docx
import org-jsoup-Jsoup- import org-jsoup-nodes-Document- import java-.docx
 
import java-util-Scanner- public class MathFunctions { public static v.docx
import java-util-Scanner- public class MathFunctions { public static v.docximport java-util-Scanner- public class MathFunctions { public static v.docx
import java-util-Scanner- public class MathFunctions { public static v.docx
 
implement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docx
implement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docximplement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docx
implement in C++ language 2- employeeId 3- basicsalary 4- displayInfo.docx
 
Implements the multiplicative binomial tree numerically- Inputs- S1- u.docx
Implements the multiplicative binomial tree numerically- Inputs- S1- u.docxImplements the multiplicative binomial tree numerically- Inputs- S1- u.docx
Implements the multiplicative binomial tree numerically- Inputs- S1- u.docx
 
Imagine that the volcano on Mt- St- Helens erupts again- All life is.docx
Imagine that the volcano on Mt- St- Helens erupts again-  All life is.docxImagine that the volcano on Mt- St- Helens erupts again-  All life is.docx
Imagine that the volcano on Mt- St- Helens erupts again- All life is.docx
 
III- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docx
III- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docxIII- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docx
III- Thres fair tetrahedra (atme as the one in part I except (tnakenta.docx
 
III Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docx
III Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docxIII Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docx
III Cld the kon to vow be lablo ol saramary satestes H0w1v2-0H1W1v2-0.docx
 
Imagine that you are planning an upcoming social media campaign for on.docx
Imagine that you are planning an upcoming social media campaign for on.docxImagine that you are planning an upcoming social media campaign for on.docx
Imagine that you are planning an upcoming social media campaign for on.docx
 
Iguana Incorporated paid a dividend of $1-85 this year- The dividend i.docx
Iguana Incorporated paid a dividend of $1-85 this year- The dividend i.docxIguana Incorporated paid a dividend of $1-85 this year- The dividend i.docx
Iguana Incorporated paid a dividend of $1-85 this year- The dividend i.docx
 
III- Assume 20 animals per group- Treatment is daily by oral gavage wi.docx
III- Assume 20 animals per group- Treatment is daily by oral gavage wi.docxIII- Assume 20 animals per group- Treatment is daily by oral gavage wi.docx
III- Assume 20 animals per group- Treatment is daily by oral gavage wi.docx
 
If the three subunits of a vertebrate ATP synthase are in the followi.docx
If the three  subunits of a vertebrate ATP synthase are in the followi.docxIf the three  subunits of a vertebrate ATP synthase are in the followi.docx
If the three subunits of a vertebrate ATP synthase are in the followi.docx
 
If the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docx
If the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docxIf the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docx
If the CPI was 9-9 in 1913 and 256 in 2019 - what was the inflation ra.docx
 
If Dorothy went to the prom with Daniel in early May- It was the perfe.docx
If Dorothy went to the prom with Daniel in early May- It was the perfe.docxIf Dorothy went to the prom with Daniel in early May- It was the perfe.docx
If Dorothy went to the prom with Daniel in early May- It was the perfe.docx
 
Identify the principal diagnosis and secondary diagnosis and place the.docx
Identify the principal diagnosis and secondary diagnosis and place the.docxIdentify the principal diagnosis and secondary diagnosis and place the.docx
Identify the principal diagnosis and secondary diagnosis and place the.docx
 
Identify the following formula- DMUsed Direct Labor + Allocated MOH Co.docx
Identify the following formula- DMUsed Direct Labor + Allocated MOH Co.docxIdentify the following formula- DMUsed Direct Labor + Allocated MOH Co.docx
Identify the following formula- DMUsed Direct Labor + Allocated MOH Co.docx
 
identify Each stage of meiosis and briefly explain what occurs during.docx
identify Each stage of meiosis and briefly explain what occurs during.docxidentify Each stage of meiosis and briefly explain what occurs during.docx
identify Each stage of meiosis and briefly explain what occurs during.docx
 
I- Construct a membership table for the following combination of the s.docx
I- Construct a membership table for the following combination of the s.docxI- Construct a membership table for the following combination of the s.docx
I- Construct a membership table for the following combination of the s.docx
 

Recently uploaded

PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxakanksha16arora
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningMarc Dusseiller Dusjagr
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 

Recently uploaded (20)

PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Our Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdfOur Environment Class 10 Science Notes pdf
Our Environment Class 10 Science Notes pdf
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 

Implementation File- -------------------------------------------------.docx

  • 1. Implementation File: --------------------------------------------------------- //----- List.cpp ----- #include <iostream> using namespace std; #include "linkedlist.h" //-- Definition of the class constructor List::List() : first(0), mySize(0) { } //-- Definition of the copy constructor List::List( const List & origList) { mySize = origList.mySize; first = 0; if (mySize == 0) return ; NodePointer origPtr, lastPtr; first = new Node(origList.first->data); // copy first node lastPtr = first; origPtr = origList.first->next; while (origPtr != 0) { lastPtr->next = new Node(origPtr->data);
  • 2. origPtr = origPtr->next; lastPtr = lastPtr->next; } } //-- Definition of the destructor inline List::~List() { NodePointer prev = first, ptr; while (prev != 0) { ptr = prev->next; delete prev; prev = ptr; } } // Definition of empty() bool List::empty() { return mySize == 0; } //-- Definition of the assignment operator const List & List:: operator =( const List & rightSide)
  • 3. { mySize = rightSide.mySize; first = 0; if (mySize == 0) return * this ; if ( this != &rightSide) { this ->~List(); NodePointer origPtr, lastPtr; first = new Node(rightSide.first->data); // copy first node lastPtr = first; origPtr = rightSide.first->next; while (origPtr != 0) { lastPtr->next = new Node(origPtr->data); origPtr = origPtr->next; lastPtr = lastPtr->next; } } return * this ; } //-- Definition of insert() void List::insert(ElementType dataVal, int index) {
  • 4. if (index < 0 || index > mySize) { cerr << "Illegal location to insert -- " << index << endl; return ; } mySize++; NodePointer newPtr = new Node(dataVal), predPtr = first; if (index == 0) { newPtr->next = first; first = newPtr; } else { for ( int i = 1; i < index; i++) predPtr = predPtr->next; newPtr->next = predPtr->next; predPtr->next = newPtr; } } //-- Definition of erase() void List::erase( int index)
  • 5. { if (index < 0 || index >= mySize) { cerr << "Illegal location to delete -- " << index << endl; return ; } mySize--; NodePointer ptr, predPtr = first; if (index == 0) { ptr = first; first = ptr->next; delete ptr; } else { for ( int i = 1; i < index; i++) predPtr = predPtr->next; ptr = predPtr->next; predPtr->next = ptr->next; delete ptr; }
  • 6. } //-- Definition of display() void List::display(ostream & out) const { NodePointer ptr = first; while (ptr != 0) { out << ptr->data << " "; ptr = ptr->next; } } //-- Definition of the output operator ostream & operator <<(ostream & out, const List & aList) { aList.display(out); return out; } nstructions: For this lab, you will write a program that reads in a list of items for a camera store. The items for the list are in a file called InventoryFile.txt. The program will give the user options to insert an item, remove an item, display the list of items, search for an item, or exit the program. Each line of the file InventoryFile has the following format: Item Number - an integer Number in stock - an integer (between 0 and 999) Unit Price - a floating-point value Minimum inventory level - an integer Item name a character string You will have to define a struct to hold the info for each item, and then your list will be an array of the struets. You will probably have to overload some operators for your struct. Your struct definition and overloaded operators should be in a separate header/implementation file from the list header/implementation. Your driver file should create the list, read in all the items, and then ask the user what to do (insert, delete, etc...), repeating until the user chooses to exit When you are done, the list should be output to a file
  • 7. called Newinventory. You will send me your driver, the list header and implementation, and the struct header and implementation. InventoryFile linkedlist1 ) No Selection