PHP code example of samdark / sack
1. Go to this page and download the library: Download samdark/sack library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
samdark / sack example snippets
declare(strict_types=1);
use Samdark\Sack\Item;
use Samdark\Sack\SackFiller;
tem('Player', 4, 3000),
new Item('Laptop', 3, 2000),
];
$sackVolume = 7;
$filler = new SackFiller($sackVolume);
$result = $filler->fill($items);
echo "Possible items:\n\n";
echo "Name\tVolume\tValue\n";
foreach ($items as $item) {
echo "{$item->getName()}\t{$item->getVolume()}\t{$item->getValue()}\n";
}
echo "\n\nMaximum value for sack of $sackVolume is {$result->getValue()}:\n\n";
echo "Name\tVolume\tValue\n";
foreach ($result->getItems() as $item) {
echo "{$item->getName()}\t{$item->getVolume()}\t{$item->getValue()}\n";
}