Guest User

Untitled

a guest
Dec 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. @Override
  2. public boolean add(Product pr)
  3. {
  4. if (!this.contains(pr)){
  5. System.out.println("Debug: Added New Product");
  6. super.add(pr);
  7.  
  8. } else {
  9. System.out.println("Debug: else");
  10.  
  11. double x = pr.getPrice();
  12. int q = pr.getQuantity();
  13.  
  14. for (int i=0; i < super.size(); i++){
  15. System.out.println("Debug: ForLoop");
  16.  
  17. if (super.get(i).equals(pr)){
  18. System.out.println("Debug: Product merge");
  19.  
  20. int w = super.get(i).getQuantity();
  21. double y = super.get(i).getPrice();
  22.  
  23. super.get(i).setQuantity(q + w);
  24. super.get(i).setPrice(y + x);
  25. }
  26. }
  27. }
  28. return true;
  29. }
Add Comment
Please, Sign In to add comment