Exemplo n.º 1
0
        /// <summary>
        /// Populates the list of auctioneers with random names
        /// </summary>
        /// <param name="list">The list where all auctioneers will be held</param>
        public void PopulateAuctioneersList(List <Auctioneer> list)
        {
            const int max = 4;

getUnusedAucioneerName:
            for (int i = 0; i < max; i++)
            {
                int nameIndex = Utilities.GetRandomNumber(0, _names_list.Count);
                if (!_used_names.Contains(_names_list[nameIndex]))
                {
                    string name = _names_list[nameIndex];
                    if (list.Count < max)
                    {
                        Auctioneer auctioneer = new Auctioneer(name, 1);
                        list.Add(auctioneer);
                        _used_names.Add(name);
                    }
                }
                else
                {
                    goto getUnusedAucioneerName;
                }
            }
        }
        /// <summary>
        /// Creates and adds a new auctioneer
        /// </summary>
        /// <param name="name">The name of the auctioneer to create</param>
        public void AddAuctioneer(string name)
        {
            Auctioneer auctioneer = new Auctioneer(name, 1);

            auctioneerList.Add(auctioneer);
        }