SlideShare a Scribd company logo
1 of 3
Download to read offline
ItemNode.h:
#include <iostream>
#include <string>
using namespace std;
class ItemNode {
private:
string item;
ItemNode* nextNodeRef;
public:
// Constructor
ItemNode() {
item = "";
nextNodeRef = NULL;
}
// Constructor
ItemNode(string itemInit) {
this->item = itemInit;
this->nextNodeRef = NULL;
}
// Constructor
ItemNode(string itemInit, ItemNode *nextLoc) {
this->item = itemInit;
this->nextNodeRef = nextLoc;
}
// Insert node after this node.
void InsertAfter(ItemNode &nodeLoc) {
ItemNode* tmpNext;
tmpNext = this->nextNodeRef;
this->nextNodeRef = &nodeLoc;
nodeLoc.nextNodeRef = tmpNext;
}
// Define InsertAtEnd() function that inserts a node
// to the end of the linked list
void InsertAtEnd(string item) {
ItemNode* newNode = new ItemNode(item);
if (nextNodeRef == NULL) {
nextNodeRef = newNode;
} else {
ItemNode* current = nextNodeRef;
while (current->nextNodeRef != NULL) {
current = current->nextNodeRef;
}
current->nextNodeRef = newNode;
}
}
// Get location pointed by nextNodeRef
ItemNode* GetNext() {
return this->nextNodeRef;
}
void PrintNodeData() {
cout << this->item << endl;
}
};
int main() {
int numItems;
cin >> numItems;
ItemNode head;
ItemNode* current = &head;
for (int i = 0; i < numItems; i++) {
string item;
cin >> item;
current->InsertAtEnd(item);
current = current->GetNext();
}
current = head.GetNext();
while (current != NULL) {
current->PrintNodeData();
current = current->GetNext();
}
return 0;
}
main.cpp (only for viewing)
#include "ItemNode.h"
int main() {
ItemNode *headNode; // Create intNode objects
ItemNode *currNode;
ItemNode *lastNode;
string item;
int i;
int input;
// Front of nodes list
headNode = new ItemNode();
lastNode = headNode;
cin >> input;
for (i = 0; i < input; i++) {
cin >> item;
currNode = new ItemNode(item);
lastNode->InsertAtEnd(currNode);
lastNode = currNode;
}
// Print linked list
currNode = headNode->GetNext();
while (currNode != NULL) {
currNode->PrintNodeData();
currNode = currNode->GetNext();
}
}
in c++ please. Thank you!
18.18 LAB: Grocery shopping list (linked list: inserting at the end of a list) Given main0, define an
InsertAtEnd() member function in the ItemNode class that adds an element to the end of a linked
list. DO NOT print the dummy head node. Ex. if the input is: begin{tabular}{|l} hline 4 Kale Lettuce
Carrots Peanuts end{tabular} where 4 is the number of items to be inserted; Kale, Lettuce,
Carrots, Peanuts are the names of the items to be added at the end of the list. The output is:

More Related Content

Similar to ItemNodeh include ltiostreamgt include ltstring.pdf

In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
Can you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdfCan you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdfFashionBoutiquedelhi
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfudit652068
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdffortmdu
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfarihantelehyb
 
take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdffastechsrv
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfanwarsadath111
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxBrianGHiNewmanv
 
Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfconnellalykshamesb60
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfEricvtJFraserr
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03Nasir Mehmood
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfanton291
 
#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docx#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docxajoy21
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docxajoy21
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfFOREVERPRODUCTCHD
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdfdeepua8
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfJUSTSTYLISH3B2MOHALI
 

Similar to ItemNodeh include ltiostreamgt include ltstring.pdf (20)

In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
PathOfMostResistance
PathOfMostResistancePathOfMostResistance
PathOfMostResistance
 
Can you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdfCan you please debug this Thank you in advance! This program is sup.pdf
Can you please debug this Thank you in advance! This program is sup.pdf
 
Implement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdfImplement the following specification of UnsortedType using circular.pdf
Implement the following specification of UnsortedType using circular.pdf
 
Linked lists
Linked listsLinked lists
Linked lists
 
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdfAssignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
Assignment isPage 349-350 #4 and #5 Use the Linked List lab.pdf
 
How to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdfHow to do insertion sort on a singly linked list with no header usin.pdf
How to do insertion sort on a singly linked list with no header usin.pdf
 
take the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdftake the following code and give details of what each line of code i.pdf
take the following code and give details of what each line of code i.pdf
 
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdfAnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
AnswerNote LinkedList.cpp is written and driver program main.cpp.pdf
 
C++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docxC++ Please write the whole code that is needed for this assignment- wr.docx
C++ Please write the whole code that is needed for this assignment- wr.docx
 
Using the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdfUsing the provided table interface table.h and the sample linked lis.pdf
Using the provided table interface table.h and the sample linked lis.pdf
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 
Data structures cs301 power point slides lecture 03
Data structures   cs301 power point slides lecture 03Data structures   cs301 power point slides lecture 03
Data structures cs301 power point slides lecture 03
 
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdfA)B) C++ program to create a Complete Binary tree from its Lin.pdf
A)B) C++ program to create a Complete Binary tree from its Lin.pdf
 
#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docx#include stdafx.h #include iostream using namespace std;vo.docx
#include stdafx.h #include iostream using namespace std;vo.docx
 
Write a program to find the number of comparisons using the binary se.docx
 Write a program to find the number of comparisons using the binary se.docx Write a program to find the number of comparisons using the binary se.docx
Write a program to find the number of comparisons using the binary se.docx
 
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdfimplement the ListLinked ADT (the declaration is given in ListLinked.pdf
implement the ListLinked ADT (the declaration is given in ListLinked.pdf
 
C code on linked list #include stdio.h #include stdlib.h.pdf
 C code on linked list #include stdio.h #include stdlib.h.pdf C code on linked list #include stdio.h #include stdlib.h.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
 
Write a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdfWrite a program that accepts an arithmetic expression of unsigned in.pdf
Write a program that accepts an arithmetic expression of unsigned in.pdf
 

More from acmefit

What can we say about these results Smokers have a nonstat.pdf
What can we say about these results Smokers have a nonstat.pdfWhat can we say about these results Smokers have a nonstat.pdf
What can we say about these results Smokers have a nonstat.pdfacmefit
 
We use the recursion xixi1+i1iN We use 00 You need to o.pdf
We use the recursion xixi1+i1iN We use 00 You need to o.pdfWe use the recursion xixi1+i1iN We use 00 You need to o.pdf
We use the recursion xixi1+i1iN We use 00 You need to o.pdfacmefit
 
The lifespan of the Ebola virus on flat dry surfaces has a n.pdf
The lifespan of the Ebola virus on flat dry surfaces has a n.pdfThe lifespan of the Ebola virus on flat dry surfaces has a n.pdf
The lifespan of the Ebola virus on flat dry surfaces has a n.pdfacmefit
 
Struter Partnership tiene un capital total de socios de 460.pdf
Struter Partnership tiene un capital total de socios de 460.pdfStruter Partnership tiene un capital total de socios de 460.pdf
Struter Partnership tiene un capital total de socios de 460.pdfacmefit
 
Question 10 Which of the following cannot be said regardin.pdf
Question 10  Which of the following cannot be said regardin.pdfQuestion 10  Which of the following cannot be said regardin.pdf
Question 10 Which of the following cannot be said regardin.pdfacmefit
 
Q5 5 marks For a natural number e let We denote the domai.pdf
Q5 5 marks For a natural number e let We denote the domai.pdfQ5 5 marks For a natural number e let We denote the domai.pdf
Q5 5 marks For a natural number e let We denote the domai.pdfacmefit
 
PF1224A Journalizing withdrawal of cash from partnership .pdf
PF1224A Journalizing withdrawal of cash from partnership .pdfPF1224A Journalizing withdrawal of cash from partnership .pdf
PF1224A Journalizing withdrawal of cash from partnership .pdfacmefit
 
Please answer the 3 questions below thank you in advance Wh.pdf
Please answer the 3 questions below thank you in advance Wh.pdfPlease answer the 3 questions below thank you in advance Wh.pdf
Please answer the 3 questions below thank you in advance Wh.pdfacmefit
 
please solve this Operators in the same row have the same pr.pdf
please solve this Operators in the same row have the same pr.pdfplease solve this Operators in the same row have the same pr.pdf
please solve this Operators in the same row have the same pr.pdfacmefit
 
a Suppose R is a partial order over set A Prove or disprov.pdf
a Suppose R is a partial order over set A Prove or disprov.pdfa Suppose R is a partial order over set A Prove or disprov.pdf
a Suppose R is a partial order over set A Prove or disprov.pdfacmefit
 
please help me with the case study Read the case study .pdf
please help me with the case study      Read the case study .pdfplease help me with the case study      Read the case study .pdf
please help me with the case study Read the case study .pdfacmefit
 
Note Use the Tax Tables to calculate the answers to the pro.pdf
Note Use the Tax Tables to calculate the answers to the pro.pdfNote Use the Tax Tables to calculate the answers to the pro.pdf
Note Use the Tax Tables to calculate the answers to the pro.pdfacmefit
 
Mayu is responsible for the security of her companys server.pdf
Mayu is responsible for the security of her companys server.pdfMayu is responsible for the security of her companys server.pdf
Mayu is responsible for the security of her companys server.pdfacmefit
 
Country Financial a financial services company uses survey.pdf
Country Financial a financial services company uses survey.pdfCountry Financial a financial services company uses survey.pdf
Country Financial a financial services company uses survey.pdfacmefit
 
Consulte la tabla a continuacin que muestra los datos de lo.pdf
Consulte la tabla a continuacin que muestra los datos de lo.pdfConsulte la tabla a continuacin que muestra los datos de lo.pdf
Consulte la tabla a continuacin que muestra los datos de lo.pdfacmefit
 
I cant seem to figure out what I am doing wrong in my PyCha.pdf
I cant seem to figure out what I am doing wrong in my PyCha.pdfI cant seem to figure out what I am doing wrong in my PyCha.pdf
I cant seem to figure out what I am doing wrong in my PyCha.pdfacmefit
 
fill in the blank What is incorrect about an SCorp a Owne.pdf
fill in the blank What is incorrect about an SCorp a Owne.pdffill in the blank What is incorrect about an SCorp a Owne.pdf
fill in the blank What is incorrect about an SCorp a Owne.pdfacmefit
 
An estimated regression equation was developed to predict th.pdf
An estimated regression equation was developed to predict th.pdfAn estimated regression equation was developed to predict th.pdf
An estimated regression equation was developed to predict th.pdfacmefit
 
Far from being rigid and inflexible the doctrine of precede.pdf
Far from being rigid and inflexible the doctrine of precede.pdfFar from being rigid and inflexible the doctrine of precede.pdf
Far from being rigid and inflexible the doctrine of precede.pdfacmefit
 
Exhibit Multiplier The marginal propensity to consume is 0.pdf
Exhibit Multiplier The marginal propensity to consume is 0.pdfExhibit Multiplier The marginal propensity to consume is 0.pdf
Exhibit Multiplier The marginal propensity to consume is 0.pdfacmefit
 

More from acmefit (20)

What can we say about these results Smokers have a nonstat.pdf
What can we say about these results Smokers have a nonstat.pdfWhat can we say about these results Smokers have a nonstat.pdf
What can we say about these results Smokers have a nonstat.pdf
 
We use the recursion xixi1+i1iN We use 00 You need to o.pdf
We use the recursion xixi1+i1iN We use 00 You need to o.pdfWe use the recursion xixi1+i1iN We use 00 You need to o.pdf
We use the recursion xixi1+i1iN We use 00 You need to o.pdf
 
The lifespan of the Ebola virus on flat dry surfaces has a n.pdf
The lifespan of the Ebola virus on flat dry surfaces has a n.pdfThe lifespan of the Ebola virus on flat dry surfaces has a n.pdf
The lifespan of the Ebola virus on flat dry surfaces has a n.pdf
 
Struter Partnership tiene un capital total de socios de 460.pdf
Struter Partnership tiene un capital total de socios de 460.pdfStruter Partnership tiene un capital total de socios de 460.pdf
Struter Partnership tiene un capital total de socios de 460.pdf
 
Question 10 Which of the following cannot be said regardin.pdf
Question 10  Which of the following cannot be said regardin.pdfQuestion 10  Which of the following cannot be said regardin.pdf
Question 10 Which of the following cannot be said regardin.pdf
 
Q5 5 marks For a natural number e let We denote the domai.pdf
Q5 5 marks For a natural number e let We denote the domai.pdfQ5 5 marks For a natural number e let We denote the domai.pdf
Q5 5 marks For a natural number e let We denote the domai.pdf
 
PF1224A Journalizing withdrawal of cash from partnership .pdf
PF1224A Journalizing withdrawal of cash from partnership .pdfPF1224A Journalizing withdrawal of cash from partnership .pdf
PF1224A Journalizing withdrawal of cash from partnership .pdf
 
Please answer the 3 questions below thank you in advance Wh.pdf
Please answer the 3 questions below thank you in advance Wh.pdfPlease answer the 3 questions below thank you in advance Wh.pdf
Please answer the 3 questions below thank you in advance Wh.pdf
 
please solve this Operators in the same row have the same pr.pdf
please solve this Operators in the same row have the same pr.pdfplease solve this Operators in the same row have the same pr.pdf
please solve this Operators in the same row have the same pr.pdf
 
a Suppose R is a partial order over set A Prove or disprov.pdf
a Suppose R is a partial order over set A Prove or disprov.pdfa Suppose R is a partial order over set A Prove or disprov.pdf
a Suppose R is a partial order over set A Prove or disprov.pdf
 
please help me with the case study Read the case study .pdf
please help me with the case study      Read the case study .pdfplease help me with the case study      Read the case study .pdf
please help me with the case study Read the case study .pdf
 
Note Use the Tax Tables to calculate the answers to the pro.pdf
Note Use the Tax Tables to calculate the answers to the pro.pdfNote Use the Tax Tables to calculate the answers to the pro.pdf
Note Use the Tax Tables to calculate the answers to the pro.pdf
 
Mayu is responsible for the security of her companys server.pdf
Mayu is responsible for the security of her companys server.pdfMayu is responsible for the security of her companys server.pdf
Mayu is responsible for the security of her companys server.pdf
 
Country Financial a financial services company uses survey.pdf
Country Financial a financial services company uses survey.pdfCountry Financial a financial services company uses survey.pdf
Country Financial a financial services company uses survey.pdf
 
Consulte la tabla a continuacin que muestra los datos de lo.pdf
Consulte la tabla a continuacin que muestra los datos de lo.pdfConsulte la tabla a continuacin que muestra los datos de lo.pdf
Consulte la tabla a continuacin que muestra los datos de lo.pdf
 
I cant seem to figure out what I am doing wrong in my PyCha.pdf
I cant seem to figure out what I am doing wrong in my PyCha.pdfI cant seem to figure out what I am doing wrong in my PyCha.pdf
I cant seem to figure out what I am doing wrong in my PyCha.pdf
 
fill in the blank What is incorrect about an SCorp a Owne.pdf
fill in the blank What is incorrect about an SCorp a Owne.pdffill in the blank What is incorrect about an SCorp a Owne.pdf
fill in the blank What is incorrect about an SCorp a Owne.pdf
 
An estimated regression equation was developed to predict th.pdf
An estimated regression equation was developed to predict th.pdfAn estimated regression equation was developed to predict th.pdf
An estimated regression equation was developed to predict th.pdf
 
Far from being rigid and inflexible the doctrine of precede.pdf
Far from being rigid and inflexible the doctrine of precede.pdfFar from being rigid and inflexible the doctrine of precede.pdf
Far from being rigid and inflexible the doctrine of precede.pdf
 
Exhibit Multiplier The marginal propensity to consume is 0.pdf
Exhibit Multiplier The marginal propensity to consume is 0.pdfExhibit Multiplier The marginal propensity to consume is 0.pdf
Exhibit Multiplier The marginal propensity to consume is 0.pdf
 

Recently uploaded

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 

Recently uploaded (20)

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 

ItemNodeh include ltiostreamgt include ltstring.pdf

  • 1. ItemNode.h: #include <iostream> #include <string> using namespace std; class ItemNode { private: string item; ItemNode* nextNodeRef; public: // Constructor ItemNode() { item = ""; nextNodeRef = NULL; } // Constructor ItemNode(string itemInit) { this->item = itemInit; this->nextNodeRef = NULL; } // Constructor ItemNode(string itemInit, ItemNode *nextLoc) { this->item = itemInit; this->nextNodeRef = nextLoc; } // Insert node after this node. void InsertAfter(ItemNode &nodeLoc) { ItemNode* tmpNext; tmpNext = this->nextNodeRef; this->nextNodeRef = &nodeLoc; nodeLoc.nextNodeRef = tmpNext; } // Define InsertAtEnd() function that inserts a node // to the end of the linked list void InsertAtEnd(string item) { ItemNode* newNode = new ItemNode(item); if (nextNodeRef == NULL) { nextNodeRef = newNode; } else { ItemNode* current = nextNodeRef; while (current->nextNodeRef != NULL) { current = current->nextNodeRef;
  • 2. } current->nextNodeRef = newNode; } } // Get location pointed by nextNodeRef ItemNode* GetNext() { return this->nextNodeRef; } void PrintNodeData() { cout << this->item << endl; } }; int main() { int numItems; cin >> numItems; ItemNode head; ItemNode* current = &head; for (int i = 0; i < numItems; i++) { string item; cin >> item; current->InsertAtEnd(item); current = current->GetNext(); } current = head.GetNext(); while (current != NULL) { current->PrintNodeData(); current = current->GetNext(); } return 0; } main.cpp (only for viewing) #include "ItemNode.h" int main() { ItemNode *headNode; // Create intNode objects ItemNode *currNode; ItemNode *lastNode; string item; int i; int input; // Front of nodes list headNode = new ItemNode(); lastNode = headNode;
  • 3. cin >> input; for (i = 0; i < input; i++) { cin >> item; currNode = new ItemNode(item); lastNode->InsertAtEnd(currNode); lastNode = currNode; } // Print linked list currNode = headNode->GetNext(); while (currNode != NULL) { currNode->PrintNodeData(); currNode = currNode->GetNext(); } } in c++ please. Thank you! 18.18 LAB: Grocery shopping list (linked list: inserting at the end of a list) Given main0, define an InsertAtEnd() member function in the ItemNode class that adds an element to the end of a linked list. DO NOT print the dummy head node. Ex. if the input is: begin{tabular}{|l} hline 4 Kale Lettuce Carrots Peanuts end{tabular} where 4 is the number of items to be inserted; Kale, Lettuce, Carrots, Peanuts are the names of the items to be added at the end of the list. The output is: