Exemplo n.º 1
0
        /// <summary>
        /// Add a bouquet to the collection.
        /// </summary>
        /// <param name="newBouquet">The bouquet to be added.</param>
        public static void AddBouquet(Bouquet newBouquet)
        {
            if (newBouquet == null)
            {
                throw (new ArgumentException("The bouquet cannot be null", "newBouquet"));
            }

            foreach (Bouquet oldBouquet in Bouquets)
            {
                if (oldBouquet.BouquetID == newBouquet.BouquetID)
                {
                    return;
                }

                if (oldBouquet.BouquetID > newBouquet.BouquetID)
                {
                    bouquets.Insert(bouquets.IndexOf(oldBouquet), newBouquet);
                    return;
                }
            }

            bouquets.Add(newBouquet);
        }
Exemplo n.º 2
0
        private static void addBouquetInNameOrder(Collection<Bouquet> sortedBouquets, Bouquet newBouquet)
        {
            foreach (Bouquet oldBouquet in sortedBouquets)
            {
                if (oldBouquet.Name.CompareTo(newBouquet.Name) > 0)
                {
                    sortedBouquets.Insert(sortedBouquets.IndexOf(oldBouquet), newBouquet);
                    return;
                }
            }

            sortedBouquets.Add(newBouquet);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a bouquet to the collection.
        /// </summary>
        /// <param name="newBouquet">The bouquet to be added.</param>
        public static void AddBouquet(Bouquet newBouquet)
        {
            if (newBouquet == null)
                throw (new ArgumentException("The bouquet cannot be null", "newBouquet"));

            foreach (Bouquet oldBouquet in Bouquets)
            {
                if (oldBouquet.BouquetID == newBouquet.BouquetID)
                    return;

                if (oldBouquet.BouquetID > newBouquet.BouquetID)
                {
                    bouquets.Insert(bouquets.IndexOf(oldBouquet), newBouquet);
                    return;
                }
            }

            bouquets.Add(newBouquet);
        }
Exemplo n.º 4
0
        private static void addBouquetInNameOrder(Collection <Bouquet> sortedBouquets, Bouquet newBouquet)
        {
            foreach (Bouquet oldBouquet in sortedBouquets)
            {
                if (oldBouquet.Name.CompareTo(newBouquet.Name) > 0)
                {
                    sortedBouquets.Insert(sortedBouquets.IndexOf(oldBouquet), newBouquet);
                    return;
                }
            }

            sortedBouquets.Add(newBouquet);
        }