{"id":23756615,"url":"https://github.com/tedyoung/supermarket-checkout-pricer-exercise","last_synced_at":"2025-09-18T00:32:44.628Z","repository":{"id":44593843,"uuid":"508348343","full_name":"tedyoung/supermarket-checkout-pricer-exercise","owner":"tedyoung","description":"Exercise for creating supermarket checkout pricer.","archived":false,"fork":false,"pushed_at":"2023-05-20T00:30:02.000Z","size":124,"stargazers_count":24,"open_issues_count":0,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-05T13:12:08.650Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tedyoung.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-28T15:08:20.000Z","updated_at":"2024-05-30T22:32:40.000Z","dependencies_parsed_at":"2024-11-21T07:30:15.804Z","dependency_job_id":"2d5bb349-954d-489f-a778-31f4f08c2358","html_url":"https://github.com/tedyoung/supermarket-checkout-pricer-exercise","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedyoung%2Fsupermarket-checkout-pricer-exercise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedyoung%2Fsupermarket-checkout-pricer-exercise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedyoung%2Fsupermarket-checkout-pricer-exercise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tedyoung%2Fsupermarket-checkout-pricer-exercise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tedyoung","download_url":"https://codeload.github.com/tedyoung/supermarket-checkout-pricer-exercise/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233433690,"owners_count":18675603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-31T19:15:43.038Z","updated_at":"2025-09-18T00:32:39.302Z","avatar_url":"https://github.com/tedyoung.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Supermarket Checkout Pricer\n\nThe aim of the exercise is to build the pricing portion of a self-service checkout machine.\nThis exercise focuses mostly on the pure Domain, but you can also try structuring it according to Hexagonal Architecture for the \"receipt printing\" feature. \n\nThe supermarket has a catalog with different types of products (rice, apples, milk, toothbrushes,...).\nEach product has a price, and the total price of the shopping cart is the total of all the prices.\n\nThe supermarket runs special deals, such as:\n - Buy two toothbrushes, get one half-off\n - 10% discount on rice\n - Bags of 1 kg of oranges $4 instead of $5.\n - and so on\n\nThese are just examples: the actual special deals changes each week, so needs to be easily configurable.\n\n## Getting Started\n\nA story to start with is:\n\n      Given a toothbrush product that has a price of $1\n      When toothbrush is added to the cart\n      Then querying cart's total price returns $1.00\n\nAnd you can follow up with:\n\n      Given toothbrush with price of $1\n      And there is a deal: buy two toothbrushes get one half-off\n      When two toothbrushes are added to the cart\n      Then querying cart's total price returns $1.50\n\n\n### TDD Hints\n\nStart with the test, of course.\n\nThink about a \"baseline\" test: what is the cart's total price when it's empty?\n\nThen when adding one product.\n\nThen when adding multiple products.\n\nThis path follows the ZOM in the ZOMbie acronym: **Z**ero, **O**ne, **M**any/**M**ore complex (while considering **B**oundaries, **I**nterfaces, and **E**xceptional cases).\n\n### Hexagonal Architecture Hints\n\nWhen handling a \"receipt printing\" story, think about where that might go.\n\nIn Hexagonal Architecture, all I/O goes into a separate class and package (e.g., `adapter.out.console.receipt.ReceiptPrinter`), while keeping the Domain \"pure\" in its own package (e.g., `domain.Cart`).\n\n## More Scenarios\n\nThe goal of the exercise is to implement pricing code in the cart that can handle different scenarios, such as the following:\n\n - The client should get a receipt with the list of products and the total price\n - The code should be able to handle the following scenarios:\n    - Buy 2 of the same item, get one 50% off\n    - Buy 3 of the same item, get one free\n    - 10% discount on certain products: 10% discount on 1kg packets of rice\n    - Buy 3 items in a single category (e.g., produce, i.e., fruits and vegetables) and get \n    - Fixed $ discounts (e.g., bag of 1kg of oranges costs $4 instead of $5)\n    - Discounts based on day of the week (e.g., Friday Special: sourdough bread 30% off)\n \n - It should be able to handle combinations of the above scenarios, when there is more than one special deal in the shopping cart items.\n\nAdapted from http://codekata.com/kata/kata01-supermarket-pricing/ and https://github.com/serenity-dojo/kata-supermarket-checkout.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedyoung%2Fsupermarket-checkout-pricer-exercise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftedyoung%2Fsupermarket-checkout-pricer-exercise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftedyoung%2Fsupermarket-checkout-pricer-exercise/lists"}