Skip to content

Conversation

Copy link

Copilot AI commented Sep 2, 2025

This PR implements the new discounted bundles feature requested in the issue. When customers buy all items in a product bundle, they receive a 10% discount on the total for those items.

Key Features

Bundle Discount Logic:

  • Only complete bundles receive discounts
  • 10% discount applied to the total price of bundle items
  • Multiple complete bundles are all discounted
  • Extra items beyond complete bundles are charged at regular price

Example Usage:

// Create a bundle offer for toothbrush + toothpaste
List<Product> bundleProducts = Arrays.asList(toothbrush, toothpaste);
teller.addBundleOffer(bundleProducts, 10.0);

// Customer buys 1 toothbrush (€0.99) + 1 toothpaste (€1.79)
// Gets 10% discount: €2.78 - €0.278 = €2.502 total

Implementation Details:

  • Added BUNDLE to SpecialOfferType enum
  • Created BundleOffer class to represent bundle offers
  • Extended Teller class with addBundleOffer() method
  • Added handleBundleOffers() method to ShoppingCart for discount calculation
  • Bundle discounts work alongside existing product-specific offers

Test Coverage:

  • Basic bundle discount functionality
  • Partial bundle handling (no discount for incomplete bundles)
  • Multiple complete bundles
  • Integration with existing offer types

The implementation follows the existing codebase patterns and maintains backward compatibility with all existing functionality.

Fixes #8.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Feature: discounted bundles Feature: Add discounted bundles support to supermarket receipt system Sep 2, 2025
Copilot AI requested a review from nstubbe September 2, 2025 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: discounted bundles

2 participants