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