Ejemplo n.º 1
0
 public static void AddProducts(Store store, params ProductForAdd[] parameters)
 {
     for (int i = 0; i < parameters.Length; i++)
     {
         ProductsArray tmpArray = GetArray(store, parameters[i].product);
         tmpArray.price = parameters[i].price;
         for (int j = 0; j < parameters[i].count; j++)
         {
             store.common_product_id++;
             tmpArray.products.Add(new Product(parameters[i].product.Name, store.common_product_id));
         }
     }
 }
Ejemplo n.º 2
0
        static private ProductsArray GetArray(Store store, Product product)
        {
            for (int i = 0; i < store.product_arrays.Count; i++)
            {
                if (store[i].name == product.Name)
                {
                    return(store[i]);
                }
            }
            ProductsArray tmp = new ProductsArray(product.Name);

            store.product_arrays.Add(tmp);
            return(tmp);
        }
Ejemplo n.º 3
0
        public static Store FindMinPriceStoreForProduct(string productName)
        {
            Store  ans = null;
            double min = 1e9;

            for (int i = 0; i < Store.stores.Count; i++)
            {
                Store tmpStore = Store.stores[i];
                for (int j = 0; j < tmpStore.product_arrays.Count; j++)
                {
                    ProductsArray tmpCategory = tmpStore.product_arrays[j];
                    if (tmpCategory.name == productName && tmpCategory.price < min)
                    {
                        min = tmpCategory.price;
                        ans = tmpStore;
                    }
                }
            }
            return(ans);
        }