Candidate List with link list in C++
//Candidate List
#include<iostream.h>
class Candidate{
public:
char* name;
int testScore;
int intMarks;
int totalScore;
Candidate *next;
Candidate(){
name="";
testScore=0;
intMarks=0;
totalScore=0;
}
void setName(char* n){
name=n;
}
void setTestScore(int s){
testScore=s;
}
void setIntMarks(int m){
intMarks=m;
}
void setTotalScore(int t){
totalScore=t;
}
int getTestScore(){
return testScore;
}
int getIntMarks(){
return intMarks;
}
int getTotalScore(){
return totalScore;
}
char* getName(){
return name;
}
void display(){
cout<<"name "<<getName()<<" \t";
cout<<"Total Score"<<getTestScore()<<" \t";
cout<<"Interview Marks"<<getIntMarks()<<" \t";
cout<<"Interview Marks"<<getTotalScore()<<" \t";
}
};
///////////////////////
class LinkedList{
Candidate *head;
public:
LinkedList(){
head = NULL; // set head to NULL
}
void addValue(char* _name,int _testScore,int _intMarks,int _totalScore){
Candidate *n = new Candidate(); // create new Node
n->name = _name; // set value
n->testScore = _testScore;
n->intMarks = _intMarks;
n->totalScore = _totalScore;
n->next = head; // make the node point to the next node.
// If the list is empty, this is NULL, so the end of the list --> OK
head = n; // last but not least, make the head point at the new node.
}
};
main(){
LinkedList list;
list.addValue("Ali",5,5,10);
list.addValue("Imran",5,5,10);
list.addValue("Umar",5,5,10);
list.addValue("Zain",5,5,10);
int a=0;
Candidate c;
c.setName("Ali");
c.setIntMarks(5);
c.setTestScore(5);
a=c.getTestScore()+c.getIntMarks();
c.setTotalScore(a);
c.display();
system("pause");
}
#include<iostream.h>
class Candidate{
public:
char* name;
int testScore;
int intMarks;
int totalScore;
Candidate *next;
Candidate(){
name="";
testScore=0;
intMarks=0;
totalScore=0;
}
void setName(char* n){
name=n;
}
void setTestScore(int s){
testScore=s;
}
void setIntMarks(int m){
intMarks=m;
}
void setTotalScore(int t){
totalScore=t;
}
int getTestScore(){
return testScore;
}
int getIntMarks(){
return intMarks;
}
int getTotalScore(){
return totalScore;
}
char* getName(){
return name;
}
void display(){
cout<<"name "<<getName()<<" \t";
cout<<"Total Score"<<getTestScore()<<" \t";
cout<<"Interview Marks"<<getIntMarks()<<" \t";
cout<<"Interview Marks"<<getTotalScore()<<" \t";
}
};
///////////////////////
class LinkedList{
Candidate *head;
public:
LinkedList(){
head = NULL; // set head to NULL
}
void addValue(char* _name,int _testScore,int _intMarks,int _totalScore){
Candidate *n = new Candidate(); // create new Node
n->name = _name; // set value
n->testScore = _testScore;
n->intMarks = _intMarks;
n->totalScore = _totalScore;
n->next = head; // make the node point to the next node.
// If the list is empty, this is NULL, so the end of the list --> OK
head = n; // last but not least, make the head point at the new node.
}
};
main(){
LinkedList list;
list.addValue("Ali",5,5,10);
list.addValue("Imran",5,5,10);
list.addValue("Umar",5,5,10);
list.addValue("Zain",5,5,10);
int a=0;
Candidate c;
c.setName("Ali");
c.setIntMarks(5);
c.setTestScore(5);
a=c.getTestScore()+c.getIntMarks();
c.setTotalScore(a);
c.display();
system("pause");
}
*********************************************************************************
By Hafiz Muhammad Umar Hayat
Comments
Post a Comment