Skip to content

Instantly share code, notes, and snippets.

Created January 29, 2021 19:43
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Tell don't ask - sales
public class Sales {
private final CrateRepository crateRepository;
private final DeliveryService deliveryService;
public Sales(CrateRepository crateRepository, DeliveryService deliveryService) {
this.crateRepository = crateRepository;
this.deliveryService = deliveryService;
public boolean sell(Integer soldCrates, ProductType type, Customer customer) {
List<Crate> crates = crateRepository.findByTypeLimit(type, soldCrates);
if (crates.size() != soldCrates) {
return false;
if (customer.getWarehouseAddressVerified()) {
Package packageToDeliver = new Package(crates, customer);
return true;
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment