/// <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); }
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); }
/// <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); }
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); }