#include <iostream.h>
#include <stdlib.h>
#include<string>
#include"LinkedList.h"

//char isValid(const string&);
int main(int argc, char *argv[])
{

char choice;
int number;
List list;
List list1; //this object is create when we add two lists.
    /*list.add(2);
    list.add(6);
    list.add(8); 
    list.add(7);   
    list.add(1);
    list.reverse(list.getHead());*/
do{
  cout<<"\n e--Enter a new node ";
  cout<<"\n i--Reverse the list ";
  cout<<"\n c--Copy the list" ; 
  cout<<"\n a--Add two lists ";
  cout<<"\n r--Replace a node with new node ";
  cout<<"\n s--Search or Find the number ";
  cout<<"\n d--Remove node ";
  cout<<"\n t--Traverse the linked list ";
  cout<<"\n q--Quit the program ";
  cout<<"\n   cmd>  ";
  cin>>choice;
  
  switch (choice){
   case 'e':
   case 'E':
      cout<<"\n Enter a number to enter in the node :";cin>>number;
      list.add(number);
  break;
  
  case 'i':
  case 'I':
    if (list.sizelist()==0)
        cout<<" \n There is no element in the list to reverse \n";
    else
        list.reverse(list.getHead());
  break;
  
  
  case 'c':
  case 'C':
    list.copy(list.getHead());
  break;
  
  case 'a':
  case 'A':
  if(list.sizelist()==0)
    cout<<"First create first list";
  else
    list1.add(11);
    list1.add(12);
    list1.add(13); 
    list1.add(14);   
    list1.add(15);
    list.addLists(list,list1);
  break;
 
  case 't':
  case 'T':
      list.traverse(list);
    break;  
  
  case 'r':
  case 'R':
      if(list.sizelist()==0)
         cout<<"\n First create the list ";
      else
        {int element;
        cout<<"\n enter element to replace = ";
        cin>>element; 
        list.replace(element);}
  break;
  
  case 's':
  case 'S':
    if(list.sizelist()==0)
       cout<<"\n First create the list ";
    else
       {int find;
        cout<<"Enter number to find ";
        cin>>find;
        if(1==list.find(find))
               cout<<find<<" exists in list"<<endl;
        else
                cout<<find<<" does not exists in list"<<endl;
        }
  break;
 
  case 'd':
  case 'D':
    if(list.sizelist()==0)
       cout<<"\n First create the list ";
    else
      list.remove();
  break;
  
  case 'q':
  case 'Q':
    exit(1);
  break;
  
  }
} while(true);

  system("PAUSE");	
  return 0;
}
