/// <summary> /// Initializes the deck of cards using queue. /// </summary> public void InitializeDeckOfCardsQueue() { for (int i = 1; i <= 4; i++) { PlayerList.Add(i); } ////Insert into queue foreach (int number in PlayerList) { ////Insert player into queue cardQueue.EnQueue(PlayerList, number); } ////Dequeue the players list1 = cardQueue.DeQueue(list1, PlayerList); ////Read data returned by the queue in list PlayerList = list1.ReadIntoList(list1); ////for each player. foreach (int playerNumber in PlayerList) { ////Distribute cards to players this.Distribute9CardsEach(playerNumber); Console.WriteLine("player " + cards.player); cards.player++; Console.WriteLine("**************"); ////Print the cards of each players this.Print(playerNumber); Console.WriteLine("**************"); } }
/// <summary> /// Reads from file. /// </summary> /// <returns>List of CompanyShares</returns> public static List <CompanyShares> ReadFromFile() { CardsQueue.LinkedList1 <CompanyShares> companysharesLinkedList = new CardsQueue.LinkedList1 <CompanyShares>(); if (File.Exists(filePath.CompanyShareFile)) { string jsonData = File.ReadAllText(filePath.CompanyShareFile); ////Getting List of CompanyShares type object from JsonFile. List <CompanyShares> jsonObjectArray = JsonConvert.DeserializeObject <List <CompanyShares> >(jsonData); ////Adding All the CompanyShares Object to CustomLinkedLsit. foreach (CompanyShares cs in jsonObjectArray) { companysharesLinkedList.AddLastIntoLinkedList(companysharesLinkedList, jsonObjectArray, cs); } return(jsonObjectArray); } else { Console.WriteLine("Specified file path does not exist"); return(new List <CompanyShares>()); } }