private void output() { for (Deal deal : deals) { System.out.println("Deal " + deal.getDate()); System.out.println( " " + deal.getBuyer().getName() + " buys from " + deal.getSeller().getName()); for (Entry<Product, Integer> entry : deal.getProducts().entrySet()) { Product product = entry.getKey(); int quantity = entry.getValue(); System.out.println( " " + product.getTitle() + " " + quantity + " x " + product.getPrice() + " = " + product.getCost(quantity)); } System.out.println("Sum: " + deal.getSum()); System.out.println("----------------------------"); outputParty(deal.getBuyer()); outputParty(deal.getSeller()); System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); } }
public double getSum() { double result = 0; for (Entry<Product, Integer> entry : products.entrySet()) { Product product = entry.getKey(); int quantity = entry.getValue(); result += product.getCost(quantity); } return result; }