Sign In
Not register? Register Now!
You are here: HomeCourseworkIT & Computer Science
Pages:
1 page/≈275 words
Sources:
No Sources
Level:
Other
Subject:
IT & Computer Science
Type:
Coursework
Language:
English (U.S.)
Document:
MS Word
Date:
Total cost:
$ 6.48
Topic:

C++ Code Creates Class Of List Needed To Be Updated (Coursework Sample)

Instructions:

This is a code that creates class of list which is needed to be updated.

source..
Content:
#include
using namespace std;
#include
class Node{
public: int get(){return object;} ;//
void set(int object){this->object=object;};
Node*getNext(){return nextNode;};
void setNext(Node *nextNode){this->nextNode=nextNode;};
private: int object;
Node*nextNode;
};
//the list class
class List{
public:
List();
void add(int addObject);
int get();
bool next();
friend void traverse(List list);
friend List addNodes();
void addProgram();
private:
int size;
Node*headNode;
Node*currentNode;
Node*lastCurrentNode;
};
//constructor implementation
List::List(){
headNode=new Node();
headNode->setNext(NULL);
currentNode=NULL;
lastCurrentNode=NULL;
size=0;
}
//add() class method implementation
void List::add(int addObject)
{
Node*newNode=new Node();
newNode->set(addObject);
if(currentNode!=NULL){
newNode->setNext(newNode->getNext());
currentNode->setNext(newNode);
lastCurrentNode=currentNode;
currentNode=newNode;
}
else
{
newNode->setNext(NULL);
headNode->setNext(newNode);
lastCurrentNode=headNode;
currentNode=newNode;
}
size++;
}
//get classmethod
int List::get()
{
if(currentNode!=NULL)
return currentNode->get();
}
//next() class method
bool List::next()
{
if(currentNode==NULL)return false;
lastCurrentNode=currentNode;
currentNode=currentNode->getNext();
if(currentNode==NULL||size==0)
return false;
else
return true;
}
//friend function to treverse linked list
Get the Whole Paper!
Not exactly what you need?
Do you need a custom essay? Order right now:

Other Topics:

  • Software Engineering With Objects Coursework Assignment
    Description: Software engineering assignment which answers questions based on the provided scenarios. it includes functional and non-functional requirements of system...
    1 page/≈275 words| No Sources | Other | IT & Computer Science | Coursework |
  • Implementation Procedures For An Educational Typology Known As xACME
    Description: The paper sets out to present implementation guidelines to help xACME educational typology meet user requirements. The project will focus on; Springfield Device and STP Configurations; Worchester Subnetting Configurations and Boston Site Protocol, Route Summarization, and Topology Improvement....
    7 pages/≈1925 words| 11 Sources | Other | IT & Computer Science | Coursework |
  • Network Design IT & Computer Science Coursework Paper
    Description: Academy, C. (2018). Private WAN Infrastructures (2.2.2) > Cisco Networking Academy Connecting Networks Companion Guide: Connecting to the WAN. [online] Ciscopress.com. Available at: http://www.ciscopress.com/articles/article.a...
    11 pages/≈3025 words| 8 Sources | Other | IT & Computer Science | Coursework |
Need a Custom Essay Written?
First time 15% Discount!