public double Run() { CustomerCalculator cc = new CustomerCalculator(avg_customers, sd_customers, max_time, milliseconds_per_refresh); CustomerGenerator cg = new CustomerGenerator(avg_items, sd_items, avg_time, sd_time); ShoppingCustomers sc = new ShoppingCustomers(); Registers rs = new Registers(num_registers, avg_processing_time, sd_processing_time, max_time); FinishedCustomers fc = new FinishedCustomers(); int current_time = 0; while (current_time <= max_time || NumCustomersInStore(sc, rs) > 0) { current_time += milliseconds_per_refresh; //Increase time List <Customer> new_customers = new List <Customer>(); if (current_time <= max_time) { int num_new_customers = cc.Update(current_time); //Calculate number of new customers new_customers = cg.GenerateCustomers(num_new_customers); //Make new customers } List <Customer> new_waiting_customers = sc.Update(new_customers, current_time); //Update the shopping customers List <Customer> new_finished_customers = rs.Update(new_waiting_customers, current_time); //Update the customers waiting in line for registers fc.Update(new_finished_customers); //Add finished customers to finished customers object. if (current_time == max_time) { Console.WriteLine("The store is now closed\n"); } //Values I want outputted to console if (current_time % output_frequency == 0) { TimeSpan t = TimeSpan.FromMilliseconds(current_time); string answer = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms", t.Hours, t.Minutes, t.Seconds, t.Milliseconds); Console.WriteLine("Current time: {0}", answer); //Console.WriteLine("Current Customer Calculator value: {0}", cc.GetModValue()); Console.WriteLine("Current number of customers finding items: {0}", sc.GetNumCustomers()); Console.WriteLine("Expected number of registers: {0}", rs.CalculateRegisters(current_time)); foreach (Register r in rs.GetRegisters()) { Console.WriteLine("Register {0} has {1} customers and {2} items", r.GetId(), r.GetNumCustomers(), r.GetNumItems()); } Console.WriteLine("Current number of finished customers: {0}", fc.GetNumCustomers()); Console.WriteLine("Current number of purchased items: {0}", fc.GetNumItems()); Console.WriteLine("-------\n"); } } TimeSpan h = TimeSpan.FromMilliseconds(current_time); string a = string.Format("{0:D2}h:{1:D2}m:{2:D2}s:{3:D3}ms", h.Hours, h.Minutes, h.Seconds, h.Milliseconds); Console.WriteLine("Current time: {0}", a); //Console.WriteLine("Average Queue Time: {0}", fc.AverageWaitTime()); return(fc.AverageWaitTime()); }