示例#1
0
        private static OrderQueue GenerateOrders(int numberOfOrders, IEnumerable <Product> products)
        {
            var rand = new Random();

            int        productCount = products.Count();
            OrderQueue queue        = new OrderQueue();

            for (int i = 0; i < numberOfOrders; i++)
            {
                var product = products.ElementAt(rand.Next(productCount));
                queue.Enqueue(new Order()
                {
                    Product         = product,
                    Quantity        = rand.Next(10),
                    DeliveryAddress = new Address()
                });
            }

            return(queue);
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NSimulate.Example3.DeliveryPerson"/> class.
 /// </summary>
 /// <param name='orderQueue'>
 /// Order queue.
 /// </param>
 public DeliveryPerson(SimulationContext context, OrderQueue orderQueue)
     : base(context)
 {
     _orderQueue = orderQueue;
 }
示例#3
0
        private static IEnumerable <DeliveryPerson> CreateDeliveryPeople(int numberOfDeliveryPeople, OrderQueue queue)
        {
            var deliveryPeople = new List <DeliveryPerson>();

            for (int i = 0; i < numberOfDeliveryPeople; i++)
            {
                deliveryPeople.Add(new DeliveryPerson(queue));
            }

            return(deliveryPeople);
        }
示例#4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NSimulate.Example3.DeliveryPerson"/> class.
 /// </summary>
 /// <param name='orderQueue'>
 /// Order queue.
 /// </param>
 public DeliveryPerson(OrderQueue orderQueue)
 {
     _orderQueue = orderQueue;
 }