Example #1
0
        public Boolean InventoryGoodsAdd(MarketGoods goods, Int32 count)
        {
            if (GoodsName != goods.GoodsName)
            {
                return(false);                              // not the same goods
            }
            if (count > goods.GoodsCount)
            {
                return(false);                          // not enough goods
            }
            GoodsPrice = (GoodsPrice * GoodsCount + goods.GoodsPrice * count) / (GoodsCount + count);
            GoodsCount = GoodsCount + count;

            return(true);
        }
Example #2
0
 public Boolean AddGoods(MarketGoods goods, Int32 count)
 {
     if (goods.GoodsCount == -1 || goods.GoodsCount > count) // enough goods to add
     {
         if (count <= LeftCapacity)                          // enough room to place the goods
         {
             if (MyGoods.Exists(t => t.GoodsName == goods.GoodsName))
             {
                 var g = MyGoods.Find(t => t.GoodsName == goods.GoodsName);
                 g.InventoryGoodsAdd(goods, count);
             }
             else
             {
                 var g = new InventoryGoods(goods, count);
                 MyGoods.Add(g);
             }
             return(true);
         }
     }
     // no enough goods or no enough space
     return(false);
 }
Example #3
0
 public InventoryGoods(MarketGoods goods, Int32 count)
     : base(goods.GoodsName, goods.GoodsPrice, count, goods.FameDown)
 {
 }