You are on page 1of 2

#include <iostream>

#include "List.h"
using namespace std;

void main()
{
int item;
int position;
List ItemList;

if (ItemList.numberOfItem() == 0)
{
cout << "No elements at this list\n";
}
cout << "Now there are : " << ItemList.numberOfItem() << " item in the
list\n\n";

for (int i = 0; i < 5; i++) //enter 5 items


{
cout << "Enter a digit : ";
cin >> item;
ItemList.addItem(item,i);
item++;
}
cout << "Now there are: " << ItemList.numberOfItem() << " item in the list\n";
cout << "The list are :\n";
ItemList.printItem();

//add data at any position


cout << "Number that you want to add:";
cin >> item;
cout << "Position : ";
cin >> position;
ItemList.addItem(item, position);
cout << "The new list :\n";
ItemList.printItem();
cout << "Now there are: " << ItemList.numberOfItem() << " item in the
list\n\n";

//delete data at any position


cout << "Delete data at which position? ";
cin >> position;
ItemList.deleteItem(position);
cout << "The new list :\n";
ItemList.printItem();
cout << "Now there are: " << ItemList.numberOfItem() << " item in the
list\n\n";

//display total
ItemList.total();

//search data
int target;
int locationWanted;
bool found = false;
cout << "Insert a target: ";
cin >> target;
do
{
found = ItemList.findItem(target, locationWanted);
if (found)
cout << "\tFound " << target << " at index "
<< locationWanted << endl;
else
cout << "\tTarget not found" << endl;
cout << "\nInsert a target, or 0 to stop: ";
cin >> target;
} while (target != 0);

You might also like