/// <summary> /// subprogram uses merge sort and temporary variables to go through every person in the linked list /// sorts all the customer based of the wait time (from least to greatest) /// updates the top 5 array /// </summary> /// <param name="updatedQueue"></param> public void UpdateTopFive(CustomerQueue updatedQueue) { //temporary customerqueue variable CustomerQueue tempQueue = updatedQueue; //temporary list that will store all the nodes from the linked list List <double> numList = new List <double>(); List <string> nameList = new List <string>(); //while the linked list is not at the end //populates the temp list for (int i = 0; i < tempQueue.GetCustomerAmount(); i++) { //adds the names and time list numList.Add(tempQueue.GetFirstCustomer().ReturnTotalTime()); nameList.Add(tempQueue.GetFirstCustomer().GetOrder()); //removes that node from the linked list tempQueue.RemoveHead(); } // calls the merge sort method (sorts the list) MergeSort(numList, nameList); //sets the 2 arrays (times and names) using the array from the temp list for (int i = 0; i < numList.Count; i++) { top5[i] = nameList[i] + Convert.ToString(numList[i]); } }
/// <summary> /// constructor for the shop simulator /// </summary> /// <param name="content">allows for content to be loaded</param> public ShopSim(ContentManager content) { //initializing the stats class stats = new Statistics(); //initializing the view shopView = new View(content); //initializing the customer nodes cashiers = new CustomerNode[4]; //no customers are added initially addingCustomer = false; //initializing the outdoor and indoor queues inCustomerQue = new CustomerQueue(); outCustomerQue = new CustomerQueue(); wholeQueue = new CustomerQueue(); }