Esempio n. 1
0
 protected override int GetHashCodeCore()
 {
     unchecked
     {
         // 23 & 31 should be coprime
         var hash = 23;
         hash = hash * 31 ^ Snack.GetHashCode();
         hash = hash * 31 ^ Quantity;
         hash = hash * 31 ^ Price.GetHashCode();
         return(hash);
     };
 }
Esempio n. 2
0
        public SnackPile(Snack snack, int quantity, decimal price)
        {
            Guard.Against.Null(snack, nameof(snack));
            Guard.Against.Negative(quantity, nameof(quantity));
            Guard.Against.Negative(price, nameof(price));
            //TODO: Price cannot be less than 0.01
            //Guard.Against.OutOfRange(price, nameof(price), 0.01m, 0);

            Snack    = snack;
            Quantity = quantity;
            Price    = price;
        }