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