示例#1
0
        public void Buy(Clothes clothes, int quantity)
        {
            var clothe = Clothes.FirstOrDefault(x => x.Type == clothes.Type && x.Size == clothes.Size && x.Color == clothes.Color);

            if (clothe != null)
            {
                clothe.Quantity += quantity;
                Money           -= clothes.BuyPrice * quantity;
            }
            else
            {
                clothes.Quantity = quantity;
                Clothes.Add(clothes);
                Money -= clothes.BuyPrice * quantity;
            }
        }
示例#2
0
        public int Sell(Clothes clothes, int quantity)
        {
            var clothe = Clothes.FirstOrDefault(x => x.Type == clothes.Type && x.Size == clothes.Size && x.Color == clothes.Color);

            if (clothe != null)
            {
                if (clothe.Quantity >= quantity)
                {
                    clothe.Quantity -= quantity;
                    Money           += clothes.SellPrice * quantity;
                    return(0);
                }
                else
                {
                    return(1);
                }
            }
            return(2);
        }