Question

ALL CODE MUST BE IN C++ Before you begin, you must write yourself a LinkedList class...

ALL CODE MUST BE IN C++

Before you begin, you must write yourself a LinkedList class and a Node class (please name your classes exactly ​as I did here). Please follow the below specifications for the two classes.

Node.cpp

● This must be a generic class.

● Should contain a generic member variable that holds the nodes value.

● Should contain a next and prev Node* as denoted here.

● All member variables should be private.

● Use public and private member functions as you deem fit.

LinkedList.cpp

● This class should be the only class creating and manipulating Node objects.

● This class must be able to handle (1) singly, (2) doubly, (3) singly-circularly, and (4) doubly-circularly linked list. When the list is created, it must be given input to which type of list it will be.

● This class must also have generic functions that are able to properly handle the generic node values.

● Your class must at least have the following public prototypes implemented.

○ bool perform_operation(int op_code, T value);

● Your class must at least have the following private prototypes implemented.

○ void append(Node* n); (Opcode 1)

○ void remove_tail(); (Opcode 2)

○ void push(Node* n); (Opcode 3)

○ Node* pop(); (Opcode 4)

○ void remove_i(int i); (Opcode 5)

○ Node* get_i(int i); (Opcode 6)

○ void add_i(Node* n, int i); (Opcode 7)

○ void print(); (Opcode 8)

○ void delete(); (Opcode 9)

○ void reverse(); (Opcode 10)

○ void rotate(int rotations); (Opcode 11)

○ void random_shuffle(); (Opcode 12)

○ int size(); (Opcode 13)

● I am not specifying all the little details in the error checking, but remember we would like to write code that does not behave unexpectedly without informing the user of error.

● The perform_opertation function should be the only function the uses the private member functions of the class. It will also be responsible for creating the nodes in memory.

Using the LinkedList class you just created, you will need to implement a priority stack through the creation of the PriorityStack class. A priority stack is similar to a stack but as in the priority queue we will pop the higher priority items first. You will need to write a main function that will test the functionality of all of your classes.

Homework Answers

Answer #1

/* This progream gives example of classes using pointers*/

#include<iostream.h>
#include<conio.h>
class student
   {
   private:
       int r_number;
       char sex;
       int age;
       float height;
       float weight;
   public:
       void getdata()
       {
       cout<<"Enter r_number\t";
       cin>>r_number;
       cout<<endl;
       cout<<"Enter sex\t";
       cin>>sex;
       cout<<endl;
       cout<<"Enter age\t";
       cin>>age;
       cout<<endl;
       cout<<"Enter height\t";
       cin>>height;
       cout<<endl;
       cout<<"Enter weight\t";
       cin>>weight;
       cout<<endl<<endl;
       }

       void display()
       {
       cout<<"r_number"<<"\t"<<r_number<<endl<<endl;
       cout<<"sex"<<"\t\t"<<sex<<endl<<endl;
       cout<<"age"<<"\t\t"<<age<<endl<<endl;
       cout<<"height"<<"\t\t"<<height<<endl<<endl;
       cout<<"weight"<<"\t\t"<<weight<<endl<<endl;
       }
   };

   void main()
   {
   student *obj;
   int i,j,n;
   clrscr();
   cout<<"enter how many students"<<endl<<endl;
   cin>>n;
   cout<<"Enter information "<<endl<<endl;
   for(i=0;i<=n-1;++i)
   {
   j=i;
   j=j+1;
   cout<<"RECORD NO\t"<<j<<endl<<endl;
   obj->getdata();
   }
   for(i=0;i<=n-1;++i)
   {
   j=i;
   cout<<"RECORD NO\t"<<j+1<<endl<<endl;
   obj->display();
   }
   getch();
   }

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Please write a class "template" AVLTree in C++. The class must be placed in a single...
Please write a class "template" AVLTree in C++. The class must be placed in a single header file called AVLTree.h The class must contain the following public member functions: -       necessary constructors for your implementation -       destructor -       isEmpty () – determines if the tree is empty - returns 1 if it is empty; 0 otherwise -       height () – returns the height of the node or -1 if a nullptr -       insert () – inserts data into the tree – must abide by AVL...
could you implement this function please, im having issues with it. void makeList (const ListNode::value_type [],const...
could you implement this function please, im having issues with it. void makeList (const ListNode::value_type [],const size_t& count) class ListNode { public: typedef int value_type; ListNode (value_type d = value_type(), ListNode* n = NULL) { datum = d; next = n; }    //Assessor value_type getDatum () const { return datum; } ListNode const* getNext () const { return next; }    //Mutator void setDatum (const value_type& d) {datum = d; } ListNode* getNext () { return next; } void...
C++ PROGRAMMING Submit the code for each problem separately. Important: Please place all appropriate coding comments...
C++ PROGRAMMING Submit the code for each problem separately. Important: Please place all appropriate coding comments inside of the code. Problem 1    Create a simple linked list program to create a class list containing class node {             void *info;              node *next; public:              node (void *v) {info = v; next = 0; }              void put_next (node *n) {next = n;}              node *get_next ( ) {return next;}              void *get_info (...
In this code, I build a single-linked list using a node class that has been created....
In this code, I build a single-linked list using a node class that has been created. How could I change this code to take data of type T, rather than int. (PS: ignore the fact that IOHelper.getInt won't work for the type T... ie second half of main). Here's my code right now: public class SLList { public SLNode head = null; public SLNode tail = null; public void add(int a) {// add() method present for testing purposes SLNode newNode...
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions...
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.) void search_node(struct linked_list* list, int find_node_ value) (The function to make) This function finds the node from the list that value is same with find_node_value and count the order of the node. This function should print message “The order of (node_value) is (order).” and error message “Function search_node : There is no such node to search.”....
Code in JAVA The requirements are as follows: The input will be in a text file...
Code in JAVA The requirements are as follows: The input will be in a text file whose name is given by arg[0] of main(). It will contain a fully-parenthesized infix expression containing only: "(", ")", "+", "-" and integers. Need help on the main and fixing the Queue. //Input: ( ( 1 + 2 ) - ( ( 3 - 4 ) + ( 7 - 2 ) ) ) ( ( 1 + 2 ) - ( 3 -...
Finish the code wherever it says TODO /**    * Node type for this list. Each...
Finish the code wherever it says TODO /**    * Node type for this list. Each node holds a maximum of nodeSize elements in an    * array. Empty slots are null.    */    private class Node {        /**        * Array of actual data elements.        */        // Unchecked warning unavoidable.        public E[] data = (E[]) new Comparable[nodeSize];        /**        * Link to next node.       ...
Data Structure in C++ I keep getting the same warning, and I cant seem to fix...
Data Structure in C++ I keep getting the same warning, and I cant seem to fix it.. Can you explain to me what I am doing wrong? Warning: dlist.cc: In function 'std::ostream& operator<<(std::ostream&, dlist&)': dlist.cc:66:10: error: invalid initialization of reference of type 'std::ostream& {aka std::basic_ostream&}' from expression of type 'dlist::node*' dlist.cc: In function 'dlist operator+(dlist&, dlist&)': dlist.cc:93:8: error: invalid operands of types 'dlist::node*' and 'dlist::node*' to binary 'operator+' dlist.cc:97:8: error: could not convert 'result' from 'int' to 'dlist' My code:...
Complete the redblacktree in Java. Add a public boolean isBlack field to the Node inner class....
Complete the redblacktree in Java. Add a public boolean isBlack field to the Node inner class. Make every Node object have a false isBlack field, all new node is red by default. In the end of the insert method, set the root node of your red black tree to be black. Implement the rotate() and recolor() functions, and create tests for them in a separate class. import java.util.LinkedList; public class BinarySearchTree<T extends Comparable<T>> { protected static class Node<T> { public...
1.Select all C++ functions that must be defined for implementing deep copies in your class which...
1.Select all C++ functions that must be defined for implementing deep copies in your class which has instance variables pointing to dynamic memories. Group of answer choices a.Default Constructor b.Copy Constructor c.Overloading assignment operator d.Writing own friend functions to directly access dynamically allocated memories e.Writing own destructor to free the allocated memory f.Overloading new operator 2. Match the memory source (right side) of the variables (left side) of the following code snippet which is a part of 'myProg' program. Note...