Skip to content

Instantly share code, notes, and snippets.


jasongorman/ Secret

Last active Dec 30, 2020
What would you like to do?
public class StockMonitor {
private final Alert alert;
private final Warehouse warehouse;
private final ReorderLevel reorderLevel;
public StockMonitor(Alert alert, Warehouse warehouse, ReorderLevel reorderLevel) {
this.alert = alert;
this.warehouse = warehouse;
this.reorderLevel = reorderLevel;
public void productSold(int productId, int quantity) {
Product product = warehouse.fetchProduct(productId);
if(needsReordering(product, quantity))
private Boolean needsReordering(Product product, int quantitySold) {
return product.getStock() - quantitySold <= reorderLevel.calculate(product);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.