The task involves implementing a checkout system for a retail store. The checkout system should be able to scan products and calculate the total price based on the pricing rules of the store. You can find more details about the task here.
- Each product has a normal price.
- Some products have special pricing rules, where buying a certain quantity of a product results in a discounted price.
scan(item): Add an item to the list of scanned items.total(): Calculate the total price of all scanned items.
- php v8.3 or higher
- Check
composer.jsonfor the full list of the packages used
- Clone the repository to your machine.
- Go to the application main root
- Run the following command
composer install
To use the checkout system:
- Instantiate the
Checkoutclass. - Scan each item using the
scan(item)method. - Get the total price using the
total()method. - Check the
PriceTestclass for some examples.
$co = new \App\Checkout\Application\Checkout();
$co->scan('A');
$co->scan('B');
$co->scan('A');
$total = $co->total(); // Calculate the total price
echo "Total: $total";vendor/bin/phpunit- I have some concerns regarding the checkout class methods signature.
- I wanted to dockerize the app but I didn't due to the time limitation.