/**
         * Creates an item with a random range of features
         */
        public static Iitem CreateRandom(double price)
        {
            Array         values           = Enum.GetValues(typeof(ItemProperties));
            TSRandom      random           = TSRandom.Instance;
            List <Object> propertiesChosen = new List <Object>();


            var itemProps = new List <ItemProperties>();
            int i         = 0;

            while (random.Next(10) < (4 - i))
            {
                //make sure there is no duplicate property
                while (true)
                {
                    var nextProperty = values.GetValue(random.Next(values.Length));
                    if (propertiesChosen.Contains(nextProperty))
                    {
                        continue;
                    }
                    propertiesChosen.Add(nextProperty);
                    break;
                }

                itemProps.Add((ItemProperties)propertiesChosen[propertiesChosen.Count - 1]);
                i++;
            }

            return(CreateSpecific(price, itemProps.ToArray()));
        }
Esempio n. 2
0
        public Store(string name)
        {
            Name   = name;
            _items = new List <Iitem>();
            _log   = Log.Instance;
            _lock  = new Object();
            _rng   = TSRandom.Instance;

            _lock    = new object();
            _running = true;
        }
Esempio n. 3
0
        public Consumer(string name, List <Store> stores)
        {
            _rng = TSRandom.Instance;

            Name    = name;
            _log    = Log.Instance;
            _stores = stores;

            _wish_list = new List <Iitem>();
            int list_count = _rng.Next(3, 5);

            for (int i = 0; i < list_count; i++)
            {
                _wish_list.Add(ItemFactory.CreateRandom(0)); // Price in this case is not imporant
            }
        }