/// <summary>
 /// Adds the node at last1.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="data">The data.</param>
 /// <param name="list1">The list1.</param>
 /// <returns>returns list after adding element in list</returns>
 public LinkedListQueue <T> AddNodeAtLast1(List <T> list, T data, LinkedListQueue <T> list1)
 {
     try
     {
         if (this.IsEmpty())
         {
             this.head = new Node <T>(data, null, null);
             this.nodeCount++;
             return(list1);
         }
         else
         {
             Node <T> currentNode = this.head;
             Node <T> newNode     = new Node <T>(data, null);
             while (currentNode.GetNext() != null)
             {
                 currentNode = currentNode.GetNext();
             }
             currentNode.SetNext(newNode);
             this.nodeCount++;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(list1);
 }
        /// <summary>
        /// Insert elements into the queue.
        /// </summary>
        /// <param name="list1">The list1 is the list of element.</param>
        /// <param name="number">The number to be inserted into queue.</param>
        /// <returns>updated List</returns>
        public LinkedListQueue <T> EnQueue(List <T> list1, T number)
        {
            try
            {
                ////Add the data into the linked list
                this.list = this.list.AddNodeAtLast1(list1, number, list);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(this.list);
        }
 /// <summary>
 /// Adds the player in list.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <returns>list after adding players in that</returns>
 public List <T> AddPlayerInList(LinkedListQueue <T> list)
 {
     try
     {
         Node <T> currentNode = new Node <T>();
         currentNode = this.head;
         while (currentNode != null)
         {
             list1.Add(currentNode.GetData());
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(list1);
 }
        /// <summary>
        /// Removes elements from the queue.
        /// </summary>
        /// <param name="list1">The list1 is the instance of the linked list.</param>
        /// <param name="list">The list is the list of elements.</param>
        /// <returns>updated linked list</returns>
        public LinkedListQueue <T> DeQueue(LinkedListQueue <T> list, List <T> list1)
        {
            try
            {
                T number;

                ////remove top element from the linked list
                number = list.DeleteFirst1();

                //// add that removed node from
                list.AddNodeAtFirst1(list1, number, list);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(list);
        }
 /// <summary>
 /// Adds the node at first1.
 /// </summary>
 /// <param name="list">The list.</param>
 /// <param name="data">The data.</param>
 /// <param name="list1">The list1.</param>
 /// <returns>list after adding element</returns>
 public LinkedListQueue <T> AddNodeAtFirst1(List <T> list, T data, LinkedListQueue <T> list1)
 {
     try
     {
         if (this.IsEmpty())
         {
             this.head = new Node <T>(data, null);
             return(list1);
         }
         else
         {
             Node <T> newNode = new Node <T>(data, null);
             newNode.SetNext(this.head);
             this.head = newNode;
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     return(list1);
 }
        /// <summary>
        /// Initializes the deck of cards.
        /// </summary>
        public void InitializeDeckOfCardsUsingQueue()
        {
            for (int i = 1; i <= 4; i++)
            {
                Playerlist1.Add(i);
            }
            foreach (int element in Playerlist1)
            {
                list = queue.EnQueue(Playerlist1, element);
            }
            list = queue.DeQueue(list, Playerlist1);

            Playerlist1 = list.AddPlayerInList(list);
            ////loops 1 time for all 4 players.
            foreach (int playerNumber in Playerlist1)
            {
                this.Distribute9Cards(playerNumber);
                Console.WriteLine("player " + this.player);
                this.player++;
                Console.WriteLine("=============");
                this.Print(playerNumber);
                Console.WriteLine("==============");
            }
        }
 /// <summary>
 /// Pushes the specified data at first position.
 /// </summary>
 /// <param name="data">The data.</param>
 public void Push(LinkedListQueue <T> list, T data)
 {
     this.AddNodeAtFirst(list, data);
 }