public SnackPile(Snack snack, int quantity, decimal price) : this()
        {
            //TODO:Unit test for the Invariants
            //Invariants
            if (quantity < 0)
            {
                throw new InvalidOperationException();
            }
            if (price < 0)
            {
                throw new InvalidOperationException();
            }
            //don't allow prices that include less than one cent : machine cannot handle such physical money
            if (price % 0.01m > 0)
            {
                throw new InvalidOperationException();
            }

            Snack    = snack;
            Quantity = quantity;
            Price    = price;
        }
Example #2
0
 public IReadOnlyList <SnackMachine> GetAllWithSnack(Snack snack)
 {
     throw  new NotImplementedException();
 }