#ifndef _LIST_H_
#define _LIST_H_

#ifndef _SHAPE_H_
  #define _SHAPE_H_
#endif

class List
{
	private:
		Node * head;

	public:
		List();
		void setHead(Node*);
		Node * getHead();
		void addNode(Node *);
		void removeNode(std::string);
		void printAreas();
		void printList();
		void printListInReverse(Node *);
};

List::List()
{
	head = new Node();
	setHead(NULL);
}

Node * List::getHead()
{
	return head;
}

void List::setHead(Node *n)
{
	head = n;
}

void List::addNode(Node *n)
{
	n->setNext(head);
	setHead(n);
}

void List::removeNode(std::string name)
{
	Node * tmp = getHead();
	while (tmp!=NULL && !(tmp->getNext() != NULL && tmp->getNext()->getShape()->getType() == name))
	{
		tmp = tmp->getNext();
	}
	if (tmp == NULL)
		std::cout<<"No Shape of that type!"<<std::endl;
	else
	{
		tmp->setNext(tmp->getNext()->getNext());	
	}			
}

void List::printAreas()
{
	Node *tmp = getHead();
        while (tmp != NULL)
        {
                std::cout<<tmp->getShape()->getArea()<<" "<<std::endl;
                tmp = tmp->getNext();
        }
}

void List::printList()
{
	Node *tmp = getHead();
	while (tmp != NULL)
	{
		std::cout<<tmp->getShape()->getType()<<" "<<std::endl;
		//tmp->printDotShape();
		tmp = tmp->getNext();
	}
}

void List::printListInReverse(Node * n)
{
	if (n != NULL )
	{
		printListInReverse(n->getNext());
		std::cout<<n->getShape()->getType()<<" ";
	}
}

#endif

