private void loadShirts()
        {
            int top = -1;

            foreach (DirectoryInfo info in dir.GetDirectories())
            {
                if (info.Name.Contains("shirt"))
                {
                    try
                    {
                        shirt newShirt = new shirt(info);
                        myList.Add(newShirt);
                        int toCompare = Convert.ToInt32(info.Name.TrimEnd('s', 'h', 'i', 'r', 't'));
                        if (top < toCompare)
                        {
                            top = toCompare;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            if (topID >= 0)
            {
                topID = top + 1;
            }
        }
        /// <summary>
        /// Return a random selection of shirts
        /// </summary>
        /// <param name="num">Number of shirts to return</param>
        /// <param name="TYPES_TO_SELECT">Types of shirts to select from</param>
        /// <returns>Collection of random shirts</returns>
        public shirt[] getRandShirts(int num, List <shirtType> TYPES_TO_SELECT)
        {
            if (myList.Count == 0)
            {
                throw new Exception("INVALID NUMBER OF ELEMENTS");
            }
            else if (num > myList.FindAll((shirt theShirt) => { return(theShirt.available); }).Count)
            {
                num = myList.FindAll((shirt theShirt) => { return(theShirt.available); }).Count;
            }
            List <int> selectedIDs = new List <int>();

            shirt[] toReturn = new shirt[num];
            for (int x = 0; x < num; x++)
            {
                bool chosen = false;
                do
                {
                    int   randNum  = rand.Next(0, myList.Count);
                    shirt selected = myList[randNum];
                    if (!selectedIDs.Contains(selected.id) && selected.available && TYPES_TO_SELECT.Contains(selected.myType)) //If it hasn't already been selected, it's available, and it's of the correct type
                    {
                        selectedIDs.Add(selected.id);
                        toReturn[x] = selected;
                        chosen      = true;
                    }
                } while (!chosen);
            }
            return(toReturn);
        }
 public bool createShirt(shirtType type, Image pic)
 {
     try
     {
         shirt newShirt = new shirt(type, pic);
         shirtManager.getShirts.addShirt(newShirt);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public void deleteShirt(shirt s)
        {
            bool success = s.destroy();

            if (success)
            {
                shirt toRemove = null;
                foreach (shirt t in myList)
                {
                    if (s.id == t.id)
                    {
                        toRemove = t;
                    }
                }
                if (toRemove != null)
                {
                    myList.Remove(toRemove);
                }
            }
        }
 /// <summary>
 /// Add a shirt to the list
 /// </summary>
 /// <param name="newShirt">Shirt to add</param>
 public void addShirt(shirt newShirt)
 {
     newShirt.id = topID++;
     myList.Add(newShirt);
     newShirt.save(dir);
 }