Guest User

Untitled

a guest
Jun 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. public class FoodServiceImpl implements FoodService {
  2.  
  3. private FruitDAO fruitDAO;
  4. private VegetableDAO vegetableDAO;
  5. private MeatDAO meatDAO;
  6.  
  7. // ... DAO injection stuff
  8.  
  9. public List<Meat> getMeat() {
  10. return meatDAO.getMeat();
  11. }
  12.  
  13. public void addMeat(Meat meat) {
  14. meatDAO.add(meat);
  15. }
  16.  
  17. public List<Fruit> getFruit() {
  18. return fruitDAO.getFruit();
  19. }
  20.  
  21. // ... tons of methods that mostly just delegate to DAOs
  22.  
  23. }
  24.  
  25. // assume foodService is injected at runtime
  26. public void controllerMethod() {
  27. foodService.getFruit();
  28. foodService.getMeat();
  29. }
  30.  
  31. // assume DAOs are injected at runtime
  32. public void controllerMethod() {
  33. fruitDAO.getFruit();
  34. meatDAO.getMeat();
  35. }
  36.  
  37. if (meat.expirationDate-today >= 5 days)
  38. FridgeDAO.store(meat)
  39. else if (meat.expirationDate-today <5 days)
  40. FreezerDAO.store(meat)
  41. else
  42. discard(meat)
Add Comment
Please, Sign In to add comment