Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public boolean add(Product pr)
- {
- if (!this.contains(pr)){
- System.out.println("Debug: Added New Product");
- super.add(pr);
- } else {
- System.out.println("Debug: else");
- double x = pr.getPrice();
- int q = pr.getQuantity();
- for (int i=0; i < super.size(); i++){
- System.out.println("Debug: ForLoop");
- if (super.get(i).equals(pr)){
- System.out.println("Debug: Product merge");
- int w = super.get(i).getQuantity();
- double y = super.get(i).getPrice();
- super.get(i).setQuantity(q + w);
- super.get(i).setPrice(y + x);
- }
- }
- }
- return true;
- }
Add Comment
Please, Sign In to add comment