Question
C++ ONLY PLEASE. =====Pickle.h===== #ifndef PICKLE_H #define PICKLE_H class Pickle { private: string type; bool bumpySkin; bool sweet; public: //CONSTRUCTORS Pickle(){} Pickle(string t, bool b,
C++ ONLY PLEASE.
=====Pickle.h=====
#ifndef PICKLE_H
#define PICKLE_H
class Pickle
{
private:
string type;
bool bumpySkin;
bool sweet;
public:
//CONSTRUCTORS
Pickle(){}
Pickle(string t, bool b, bool swe)
{
this->type = t;
this->bumpySkin = b;
this->sweet = swe;
}
//OVERLOADED
friend ostream & operator
{
os
os
if(p.bumpySkin)
os
else
os
os
if(p.sweet)
os
else
os
return os;
}
//OVERLOADED relational operators to be able to search for a specific pickle object by type
bool operator !=(const Pickle& p)
{
if(this->type != p.type)
return true;
else
return false;
}
//OVERLOADED == OPERATOR to be able to search for a specific pickle object by type
bool operator ==(const Pickle& p)
{
if(this->type == p.type)
return true;
else
return false;
}
};
#endif
=================================================================================
=========LinkedList.h=========
#ifndef LinkedList_H
#define LinkedList_H
#include
using namespace std;
template
class LinkedList
{
private:
struct ListNode
{
//STRUCTURE MEMBERS NEED TO BE ADDED HERE
};
ListNode *head;
ListNode *tail;
public:
LinkedList()
{
head = NULL;
tail = NULL;
}
~LinkedList();
void appendNode(T value);
void deleteNode(int position);
void displayList() const;
};
//DEFINE ALL OTHER LinkedList class FUNCTIONS BELOW THIS LINE--------------------------------
#endif
================================================================================
======Driver.cpp=======
#include
#include //for the toupper function
#include //to use numeric_limits
#include "LinkedList.h"
#include "Pickle.h"
using namespace std;
void printPickle();
int main()
{
LinkedList list;
int num;
char response;
//Print some cute pickle art
printPickle();
cout
cin.get();
//ADD SOME PICKLES
cout
Pickle pickle1("Bread-and-butter", false, true);
list.appendNode(pickle1);
Pickle pickle2("Gherkin", true, true);
list.appendNode(pickle2);
Pickle pickle3("Kosher Dill", true, false);
list.appendNode(pickle3);
Pickle pickle4("Hungarian", false, false);
list.appendNode(pickle4);
Pickle pickle5("Lime", false, false);
list.appendNode(pickle5);
cout
list.displayList();
cout
cin >> num;
//input validation loop
while(!cin || num 5) //!cin tests if the input good bit (ios::good) is not true
{
cin.clear(); //sets ios::good back to true and all other bits back to false
/*
The ignore below will remove all leftover characters or numbers
from keyboard buffer to start with fresh input.
Also, you must #include to use numeric_limits
*/
cin.ignore(numeric_limits::max(),' ');
cout
cin >> num;
}
list.deleteNode(num-1);
cout
cin >> response;
//input validation loop
while(!cin || toupper(response) != 'Y' && toupper(response) != 'N')
{
cin.clear();
cin.ignore(numeric_limits::max(),' ');
cout
cin >> response;
}
if(toupper(response) == 'Y')
{
cout
list.displayList();
}
cout
cin.get();
cout
cout
return 0;
}
/*
Function: printPickle()
Purpose: print a cute pickle in ASCII art to the screen
*/
void printPickle()
{
}
5:46 O Qill 53% 1. a. Download the given files from ilearn: Pickle.h - class specification file for a Pickle class (no additions or edits should be made to this file] b. Driver.cpp - driver for your program [no additions or edits should be made to this file] LinkedList.h - you will be completing this template LinkedList class as your lab assignment C. 2. Read through the given code for understanding and to get familiar with it and view the sample output at the bottom. 3. Implement the linked list template class in LinkedList.h. The class declaration is written for you except for entering the correct structure members. You will need to implement all the public member functions except for the constructor, which is already implemented as an inline member function. appendNode function accept the template data 0 type as a parameter dynamically allocate a new ListNode and set the ListNode's value to the value sent to this function place the new node at the end of the linked list (use the tail pointer to help!) deleteNode function O accept an integer position 5:46 Quill 53% 3. Implement the linked list template class in LinkedList.h. The class declaration is written for you except for entering the correct structure members. You will need to implement all the public member functions except for the constructor, which is already implemented as an inline member function. o appendNode function accept the template data type as a parameter dyn ally allocate a new ListNode and set the ListNode's value to the value sent to this function place the new node at the end of the linked list (use the tail pointer to help!) deleteNode function accept an integer position which indicates which node should be deleted. Position zero is the first node. 0 If the linked list is empty, stop this function from running If the position sent to this function is zero, delete the head node and make sure to print out "-----DELETING the node with address: " and then print the node's memory address. 5:46 PM till 53% function is zero, delete the head node and make sure to print out----DELETING the node with address: " and then print the node's memory address. Otherwise, traverse the linked list to search for a node at the given position (if it exists) and delete it. Make sure to print out "-----DELETING the node with address: and then print the node's memory address that you are deleting. displayList function If there are no nodes in the list, just print out that there are no nodes in the list. Otherwise, traverse the linked list and print out each node EXACTLY like the sample output (given below)! Destructor O 0 Delete all nodes that remain in the linked list Before deleting the node, make sure to print out ******DELETING the node with address: " and then print the node's memory address that you are 5:46 O Qill 53% 1. a. Download the given files from ilearn: Pickle.h - class specification file for a Pickle class (no additions or edits should be made to this file] b. Driver.cpp - driver for your program [no additions or edits should be made to this file] LinkedList.h - you will be completing this template LinkedList class as your lab assignment C. 2. Read through the given code for understanding and to get familiar with it and view the sample output at the bottom. 3. Implement the linked list template class in LinkedList.h. The class declaration is written for you except for entering the correct structure members. You will need to implement all the public member functions except for the constructor, which is already implemented as an inline member function. appendNode function accept the template data 0 type as a parameter dynamically allocate a new ListNode and set the ListNode's value to the value sent to this function place the new node at the end of the linked list (use the tail pointer to help!) deleteNode function O accept an integer position 5:46 Quill 53% 3. Implement the linked list template class in LinkedList.h. The class declaration is written for you except for entering the correct structure members. You will need to implement all the public member functions except for the constructor, which is already implemented as an inline member function. o appendNode function accept the template data type as a parameter dyn ally allocate a new ListNode and set the ListNode's value to the value sent to this function place the new node at the end of the linked list (use the tail pointer to help!) deleteNode function accept an integer position which indicates which node should be deleted. Position zero is the first node. 0 If the linked list is empty, stop this function from running If the position sent to this function is zero, delete the head node and make sure to print out "-----DELETING the node with address: " and then print the node's memory address. 5:46 PM till 53% function is zero, delete the head node and make sure to print out----DELETING the node with address: " and then print the node's memory address. Otherwise, traverse the linked list to search for a node at the given position (if it exists) and delete it. Make sure to print out "-----DELETING the node with address: and then print the node's memory address that you are deleting. displayList function If there are no nodes in the list, just print out that there are no nodes in the list. Otherwise, traverse the linked list and print out each node EXACTLY like the sample output (given below)! Destructor O 0 Delete all nodes that remain in the linked list Before deleting the node, make sure to print out ******DELETING the node with address: " and then print the node's memory address that you areStep 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