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

class ListItem
{
	public:
		string Data;
		ListItem *Next;
};

class List
{
	private:
	    ListItem *root = nullptr;
	    ListItem *last = nullptr;
	    
	public:
	   ~List();
	   void Anhaengen(string data);
	   void Ausgabe();
	   int GetCount();
	   
};

List::~List()
{
	ListItem *helper;
    while (this->root != nullptr)
    {
        helper = this->root;
        this->root = this->root->Next;
        delete(helper);
    }
}

void List::Anhaengen(string data)
{
	ListItem *item = new(ListItem);
	item->Data = data;
	item->Next = nullptr;
	if(this->root == nullptr)
	{
		this->root = item;
		this->last = item;
	}
	else
	{
		this->last->Next = item;
		this->last = item;
	}
}

void List::Ausgabe()
{
	ListItem *helper = this->root;
 
    while (helper != nullptr)
    {
    	cout << helper->Data << endl;
        helper = helper->Next;
    }  
}

int List::GetCount()
{
	int count = 0;
	ListItem *helper = this->root;
	
	while (helper != nullptr)
    {
        helper = helper->Next;
		count++;
    }  
	
	return count;
}

int main() {
	
	List list;
	
	for(int i = 1; i < 11; i++)
		list.Anhaengen("Test" + std::to_string(i));
	
	list.Ausgabe();
	cout << "Items: " << list.GetCount() << endl;

	// your code goes here
	return 0;
}