Skip to content

Commit

Permalink
Added class for List type
Browse files Browse the repository at this point in the history
  • Loading branch information
jimtahu committed Apr 26, 2013
1 parent a3aaf34 commit cc96900
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
28 changes: 28 additions & 0 deletions ListVariable.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* List.cpp
*
* Created on: Apr 25, 2013
* Author: jimtahu
*/

#include "ListVariable.h"

ListVarable::ListVarable(string name):Variable(name) {
this->head=NULL;
}

void ListVarable::add(string value){
ListItem *item = new ListItem();
item->value=value;
item->next=this->head;
this->head=item;
}

ListVarable::~ListVarable() {
ListItem *item = this->head;
while(this->head != NULL){
this->head=item->next;
delete item;
item=this->head;
}//end while list items
}
28 changes: 28 additions & 0 deletions ListVariable.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* List.h
*
* Created on: Apr 25, 2013
* Author: jimtahu
*/

#ifndef LIST_H_
#define LIST_H_

#include "Variable.h"

class ListItem {
public:
string value;
ListItem *next;
public:
};

class ListVarable: public Variable {
ListItem *head;
public:
ListVarable(string name);
void add(string value);
virtual ~ListVarable();
};

#endif /* LIST_H_ */
6 changes: 3 additions & 3 deletions Variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ class Variable {
public:
Variable(string name);
Variable(Variable &other);
string GetName();
string GetValue();
void SetValue(string value);
virtual string GetName();
virtual string GetValue();
virtual void SetValue(string value);
virtual ~Variable();
};

Expand Down

0 comments on commit cc96900

Please sign in to comment.