https://github.com/ebkr/unidaystechplacement
https://github.com/ebkr/unidaystechplacement
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ebkr/unidaystechplacement
- Owner: ebkr
- Created: 2018-11-22T01:49:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-11-22T02:49:29.000Z (over 6 years ago)
- Last Synced: 2025-01-14T12:29:48.724Z (4 months ago)
- Language: Java
- Size: 7.81 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# UnidaysTechPlacement
## The repository contains a batch file to compile and run the Main class.### Discounts
I approached the solution by working on how I'd enable discounts first.
It took several iterations, but I came up with a method that would work perfectly.
This method is the PricingRule class, and is initialised by {normalPrice, quantityToApplyDiscount, discountPrice}.
### Pricing
Once items are added to the basket, they have their price calculated. This works by finding how many of each item there are stored, and applying the discount based on the quantity.
For example, 5 items, with a rule of {2, 2, 1} would be:
2 groups of 2 match required quantity. Therefore, total += 2*discountPrice.
There is 1 item remaining, Therefore, total += 1*normalPrice.
## Total
I've used a BasketResult class to display the total cost, and the delivery charge.