content: package santamarket.model;
  
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.List;
  import java.util.Objects;
  
  public class Receipt {
      private final List<ReceiptItem> items = new ArrayList<>();
      private final List<Discount> discounts = new ArrayList<>();
  
      public double getTotalPrice() {
          double total = 0.0;
          for (ReceiptItem item : items) {
              total += item.getTotalPrice();
          }
          for (Discount discount : discounts) {
              total += discount.getDiscountAmount();
          }
          return total;
      }
  
      public void addProduct(Product p, double quantity, double price, double totalPrice) {
          items.add(new ReceiptItem(p, quantity, price, totalPrice));
      }
  
      public List<ReceiptItem> getItems() {
          return Collections.unmodifiableList(items);
      }
  
      public void addDiscount(Discount discount) {
          discounts.add(discount);
      }
  
      public List<Discount> getDiscounts() {
          return discounts;
      }
  
      @Override
      public boolean equals(Object o) {
          if (this == o) return true;
          if (o == null || getClass() != o.getClass()) return false;
          Receipt receipt = (Receipt) o;
          return Objects.equals(items, receipt.items) && Objects.equals(discounts, receipt.discounts);
      }
  
      @Override
      public int hashCode() {
          return Objects.hash(items, discounts);
      }
  }
  