Beispiel #1
0
        public void SetSnackTypeId(int snackTypeId)
        {
            if (SnackType.Id == snackTypeId)
            {
                throw new IncorrectSlotDataException(nameof(snackTypeId));
            }

            SnackType = SnackType.FromId(snackTypeId);
        }
Beispiel #2
0
        public Slot(int position, int itemsQuantity, decimal itemPrice, int snackTypeId)
        {
            _position = position > 0 ? position : throw new IncorrectSlotDataException(nameof(position));

            if (itemsQuantity < 0)
            {
                throw new IncorrectSlotDataException(nameof(itemsQuantity));
            }
            _itemsQuantity = itemsQuantity;

            if (itemPrice < 0 || itemPrice % 0.01m > 0)
            {
                throw new IncorrectSlotDataException(nameof(itemPrice));
            }
            _itemPrice = itemPrice;

            SnackType = snackTypeId > 0 ? SnackType.FromId(snackTypeId)
                : throw new IncorrectSlotDataException(nameof(snackTypeId));
        }