* @since 1.0.0 */ private array $items = []; /** * Constructor. * * @param float $maxCost Maximum amount of costs the backpack can hold * * @since 1.0.0 */ public function __construct(float $maxCost) { $this->maxCost = $maxCost; } /** * {@inheritdoc} */ public function getValue() : float { return $this->value; } /** * {@inheritdoc} */ public function getCost() : float { return $this->cost; } /** * {@inheritdoc} */ public function getMaxCost() : float { return $this->maxCost; } /** * {@inheritdoc} */ public function getItems() : array { return $this->items; } /** * {@inheritdoc} */ public function addItem(ItemInterface $item, int|float $quantity = 1) : void { $this->items[] = ['item' => $item, 'quantity' => $quantity]; $this->value += $item->getValue() * $quantity; $this->cost += $item->getCost() * $quantity; } }