public SnackPile(Snack snack, int quantity, decimal price) { if (quantity < 0) { throw new InvalidOperationException(); } if (price < 0 || price % 0.01m > 0) { throw new InvalidOperationException(); } this.Snack = snack; this.Quantity = quantity; this.Price = price; }