Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write in C++, i am totally clueless 1. Design and program necessary C++ C

ID: 3596821 • Letter: P

Question

Please write in C++, i am totally clueless

1. Design and program necessary C++ Classes with data members and member functions for above functions.

2. For each Class designed, provide default constructor, copy constructor, and constructor with arguments.

3. A Driver application to test the graph and demonstrate its functions.

4. Apply at least three of the following techniques (any 3): inheritance; polymorphism; operator overloading; template; exception handling

Problem statement A directed graph is graph, i.e., a set of objects (called vertices or nodes) that are connected together, where all the edges are directed from one vertex to another. In contrast, a graph where the edges are bidirectional is called an undirected graph. A graph can be formally define as G=(N,E) consisting of the set N of nodes and the set E of edges, which are ordered pairs of elements of N. It is further assumed in this project specification that any graph is finite with no directed or undirected cycles. An example is given below for directed graph V=(1,2,3,4,5,6) E= {(1,2),(1,4),(2,3),(2,4),(2,5),(3,4),(5,3 ) , (6,3),(6,5)} 2 3 6 4 A graph has many useful applications in the real world, such as scheduling of tasks network topology; family tree; data compression; literature citation, social connections and so orn This project requires you to develop object oriented programs of a graph that can achieve the following functions 1. 2. 3. 4. 5. 6. A graph can be empty with no vertex or edge A graph can be either a directed graph or an undirected graph A graph can be added in vertices and edges A vertex of a graph can contain values - in theory, the values can be of any type A graph can be displayed by listing all the possible paths, each linking vertices. A graph can be queried by given a starting vertex, listing the path this vertex leads A graph can be queried by given an edge, if this edge exists in the graph A graph can be queried if a value is contained by any of its vertex 7. 8.

Explanation / Answer

#ifndef List_h
#define List_h

#include "Node.h"
#include "Pair.h"
#include<string>

using namespace std;

class List{
private:
    int size;
    Node<string>* headPtr;

public:
    List(); //default constructor
    List(const List& anotherList); //copy constructor -iffy, I'm not sure if my definition for this function is correct-
    virtual ~List(); //destructor
    void insert(Pair data); //insert item
    bool remove(Pair data); //remove item
    bool find(Pair data); //find item
    int getSize(); //size of list
    bool isEmpty(); //checks if list is empty
    void clear(); //clear list
};
#include "List.cpp"
#endif
.cpp

//inserting data to list
void List::insert(Pair data){

        Node<string>* newptr = new Node<string> (); //create new node
        newptr->setItem(data); //set character into node
        newptr->setNext(headPtr); //sets the ptr to headptr(null)
        headPtr = newptr; //headptr points to the node you've just created
        size++; //increment the size
}


//clears the entire list
void List::clear(){
    Node<string>* delPtr = headPtr; //delPtr points to the top of the list
    while(delPtr != nullptr){
        headPtr = delPtr->getNext(); //sets the head pointer to the next node
        delPtr->setNext(nullptr); //begins the process of removing the data from the top of the list here
        delete delPtr;
        delPtr = headPtr; //sets the delPtr to the headptr after deleting this way we will continue to delete data from the list until the list is empty
    }

    headPtr = nullptr;
    delPtr = nullptr;
    size = 0;
}

//destructor
List::~List() {
    clear();
}
Here is how my Pair.h file looks:

#ifndef _Pair_h
#define _Pair_h

#include<iostream>
#include<string>
using namespace std;

class Pair{
private:
    string key;
    string value;
protected:
    void setKey(const string& key);

public:
    Pair();
    Pair(string aValue, string key);
    string getValue() const;
    string getKey() const;
    void setValue(const string& aValue);

};

#include "Pair.cpp"
#endif
Here is my Node.h file:

#ifndef _NODE
#define _NODE


template<class ItemType>
class Node
{
private:
   ItemType item; // A data item
   Node<ItemType>* next; // Pointer to next node

public:
   Node();
   Node(const ItemType& anItem);
   Node(const ItemType& anItem, Node<ItemType>* nextNodePtr);
   void setItem(const ItemType& anItem);
   void setNext(Node<ItemType>* nextNodePtr);
   ItemType getItem() const ;
   Node<ItemType>* getNext() const ;
}; // end Node

#include "Node.cpp"
#endif