Question
PLEASE DONT COPY PREVIOUS ANSWERS .. DONT MODIFY ANYTHING FROM THE CLASS . /* Use the comments given in each routine to complete the following
PLEASE DONT COPY PREVIOUS ANSWERS .. DONT MODIFY ANYTHING FROM THE CLASS . /* Use the comments given in each routine to complete the following program */
#include
#include
using namespace std;
class Node;
typedef Node* NodePtr;
class CircularDLL;
class Node
{
friend class CircularDLL;
private:
int stId;
string stName;
string stEmail;
int stAge;
NodePtr next;
};
class CircularDLL
{
private:
NodePtr top;
void destroy (NodePtr&);
public:
CircularDLL();
CircularDLL(const CircularDLL& source);
~CircularDLL();
void insertDataFromFile();
void print ();
bool search (int);
void insertAfterFirst (int id, string name, string email, int age);
void insertBeforeFirst (int id, string name, string email, int age);
void insertAfterLast (int id, string name, string email, int age);
void insertBeforeLast (int id, string name, string email, int age);
void remove (int);
void copy (NodePtr top1, NodePtr& top2);
};
//--------------------------------------------
//--------------------------------------------
// the default constructor
CircularDLL::CircularDLL()
{
}
//--------------------------------------------
//--------------------------------------------
// the copy constructor
CircularDLL::CircularDLL(const CircularDLL& source)
{
}
//--------------------------------------------
//--------------------------------------------
// the destructor
CircularDLL::~CircularDLL()
{
}
//--------------------------------------------
//--------------------------------------------
// Read a transaction file and insert the data into it
// after reading a set of data you can call any of the
// insert functions to insert the node into the linked list
/* use the following data to test your program
76543Marymary@csusm.edu19
98765Kathykathy@csusm.edu30
16438Floraflora@csusm.edu25
43260Peterpeter@csusm.edu29
87590kimkim@csusm.edu31
*/
void CircularDLL::insertDataFromFile()
{
}
//--------------------------------------------
//--------------------------------------------
// print the linked list
void CircularDLL::print ()
{
}
//--------------------------------------------
//--------------------------------------------
// search for a particular student id in the list
bool CircularDLL::search (int id)
{
return true;
}
//--------------------------------------------
//--------------------------------------------
// creates a node and insert the node on the top of the
// linked list but after the first node. For example if the
// list constains 1 <--> 20 <-->13 <--> 4 <--> 5 <--> 6 <--> (links to the first node which is 1)
// after inserting 10, we should get:
// list constains 1 <--> 10 <--> 20 <-->13 <--> 4 <--> 5 <--> 6 <--> (links to the first node which is 1)
void CircularDLL::insertAfterFirst (int id, string name, string email, int age)
{
}
//--------------------------------------------
//--------------------------------------------
// creates a node and insert the node on the top of the
// linked list before the first node. For example if the
// list constains 1 <--> 20 <-->13 <--> 4 <--> 5 <--> 6 <--> (links to the first node which is 1)
// after inserting 10, we should get:
// list constains 10 <--> 1 <--> 20 <-->13 <--> 4 <--> 5 <--> 6 <--> (links to the first node which is 10)
void CircularDLL::insertBeforeFirst (int id, string name, string email, int age)
{
}
//--------------------------------------------
//--------------------------------------------
// creates a node and insert the node on the bottom of the
// linked list after the last node. For example if the
// list constains 1 <--> 20 <-->13 <--> 4 <--> 5 <--> 6 <--> (links to the first node which is 1)
// after inserting 10, we should get:
// list constains 1 <--> 20 <-->13 <--> 4 <--> 5 <--> 6 <--> 10 <-->(links to the first node which is 1)
void CircularDLL::insertAfterLast (int id, string name, string email, int age)
{
}
//--------------------------------------------
//--------------------------------------------
// creates a node and insert the node on the bottom of the
// linked list before the last node. For example if the
// list constains 1 <--> 20 <-->13 <--> 4 <--> 5 <--> 6 <--> (links to the first node which is 1)
// after inserting 10, we should get:
// list constains 1 <--> 20 <-->13 <--> 4 <--> 5 <--> 10 <--> 6 <--> (links to the first node which is 1)
void CircularDLL::insertBeforeLast (int id, string name, string email, int age)
{
}
//--------------------------------------------
//--------------------------------------------
// removes a node from the list based on the given student id
void CircularDLL::remove (int id)
{
}
//--------------------------------------------
//--------------------------------------------
// copies one list into another
void CircularDLL::copy (NodePtr atop, NodePtr& btop)
{
}
//--------------------------------------------
// deallocate the nodes in a linked list
void CircularDLL::destroy(NodePtr& top)
{
}
//--------------------------------------------
int main ()
{
CircularDLL list1;
list1.insertDataFromFile();
list1.print();
list1.insertAfterFirst (54321, "Jim", "jim@csusm.edu", 25);
list1.insertBeforeFirst (54123, "Joe", "joe@csusm.edu", 35);
list1.insertAfterLast (63421, "Adam", "adam@csusm.edu", 20);
list1.insertBeforeLast (66641, "Nancy", "nancy@csusm.edu", 27);
list1.print();
bool found = list1.search (12321);
if (found)
cout << "the record was found" << endl;
else
cout << "the record was not found" << endl;
list1.remove (54321);
list1.print();
CircularDLL list2(list1);
list2.print();
return 0;
}
//--------------------------------------------
Step 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