David Bylund - #156
Open
ReRaulReb wants to merge 15 commits into
Open
David Bylund#156ReRaulReb wants to merge 15 commits into
ReRaulReb wants to merge 15 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a basic “Bob’s Bagels” domain model (basket, items, inventory, customers) with item subtypes and an accompanying JUnit test suite, plus a Mermaid class diagram describing the intended design.
Changes:
- Added core domain classes:
Basket,Item,Inventory,Customer, and item subtypes (Bagel,Coffee,Filling). - Implemented receipt/total-cost calculation with multi-buy discount handling and console receipt output.
- Added JUnit tests covering adding/removing items, capacity limits, discount application, and receipt output.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/booleanuk/core/Basket.java | Basket storage, add/remove operations, total/receipt generation, and discount aggregation. |
| src/main/java/com/booleanuk/core/Customer.java | Simple customer wrapper owning a basket. |
| src/main/java/com/booleanuk/core/Inventory.java | SKU-backed catalog for price/name/type and discount metadata. |
| src/main/java/com/booleanuk/core/Item.java | Base item model populated from Inventory. |
| src/main/java/com/booleanuk/core/Manger.java | “Manager” concept for changing basket capacity (static). |
| src/main/java/com/booleanuk/core/item_types/Bagel.java | Item subtype enforcing bagel-only SKUs. |
| src/main/java/com/booleanuk/core/item_types/Coffee.java | Item subtype enforcing coffee-only SKUs. |
| src/main/java/com/booleanuk/core/item_types/Filling.java | Item subtype enforcing filling-only SKUs. |
| src/test/java/com/booleanuk/core/BasketTest.java | Tests for add/remove, capacity limits, discounts, and printed receipt output. |
| src/test/java/com/booleanuk/core/CustomerTest.java | Tests that customer exposes a basket. |
| src/test/java/com/booleanuk/core/ItemTest.java | Tests for basic Item accessors and invalid SKU behavior. |
| src/test/java/com/booleanuk/core/MangerTest.java | Test for resizing basket capacity via manager class. |
| src/test/java/com/booleanuk/core/item_types/BagelTest.java | Tests invalid bagel SKU type handling. |
| src/test/java/com/booleanuk/core/item_types/CoffeeTest.java | Tests invalid coffee SKU type handling. |
| src/test/java/com/booleanuk/core/item_types/FillingTest.java | Tests invalid filling SKU type handling. |
| model.md | Mermaid class diagram documenting intended structure/relationships. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+44
to
+61
| public boolean removeItem(String sku){ | ||
| for (int i = 0; i < this.curSize; i++){ | ||
|
|
||
| if(this.arr[i].getSKU() == sku){ | ||
| for (int j = i; j < this.curSize; j++){ | ||
| if (j+1 >= this.curSize){ | ||
| this.arr[j] = null; | ||
| break; | ||
| } | ||
| this.arr[j] = this.arr[j+1]; | ||
| } | ||
| this.arr[i] = this.arr[i+1]; | ||
| this.curSize--; | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } |
Comment on lines
+3
to
+6
| public class Manger extends Basket{ | ||
| public static void changeBasketSize(int size){ | ||
| Basket.size = size; | ||
| } |
| @@ -0,0 +1,7 @@ | |||
| package com.booleanuk.core; | |||
|
|
|||
| public class Manger extends Basket{ | |||
Comment on lines
+5
to
+8
| protected String sku; | ||
| protected String varient; | ||
| protected String name; | ||
| protected int discountCondition; |
Comment on lines
+27
to
+33
| public float getPrice(String sku){ | ||
| return (float) this.inventory.get(sku)[0]; | ||
| } | ||
|
|
||
| public String getVarient(String sku){ | ||
| return (String) this.inventory.get(sku)[1]; | ||
| } |
Comment on lines
+58
to
+64
| // @Test | ||
| // public void getTotalCostTest() throws Exception{ | ||
| // b.addBagel("BGLP"); // 0.39 | ||
| // b.addCoffee("COFB"); // 0.99 | ||
| // b.addFilling("FILB"); // 0.12 | ||
| // Assertions.assertEquals(0.39 + 0.99 + 0.12, b.getTotalCost(), 0.0001); | ||
| // } |
Comment on lines
+9
to
+17
| public MangerTest(){ | ||
| this.m = new Manger(); | ||
| } | ||
|
|
||
| @Test | ||
| public void changeBasketSizeTest(){ | ||
| Manger.changeBasketSize(35); | ||
| Assertions.assertEquals(35, m.getMaxSize()); | ||
| } |
Comment on lines
+28
to
+32
| @Test | ||
| public void getVarientTest(){ | ||
| Item i = new Item("COFB"); | ||
| Assertions.assertEquals("Coffee", i.getVarient()); | ||
| } |
Comment on lines
+12
to
+27
| public Item(String sku) { | ||
| this.inventory = new Inventory(); | ||
| try{ | ||
| this.sku = sku; | ||
| this.price = this.inventory.getPrice(sku); | ||
| this.varient = this.inventory.getVarient(sku); | ||
| this.name = this.inventory.getName(sku); | ||
| this.discountCondition = this.inventory.getDiscountCondition(sku); | ||
| this.discount = this.inventory.getDiscount(sku); | ||
| } | ||
| catch (Exception e){ | ||
| System.out.println("Not a valid SKU"); | ||
| throw e; | ||
| } | ||
|
|
||
| } |
Comment on lines
+95
to
+99
| Pair pair = entry.getValue(); | ||
| String nameVarient = this.inventory.getName(sku) + " " + this.inventory.getVarient(sku); | ||
| String price = "£" + String.format("%.2f", this.inventory.getPrice(sku)*pair.count); | ||
| String amountPrice = paddTwo(10, ""+ pair.count, price); | ||
| tmp += paddTwo(maxStringSize, nameVarient, amountPrice)+ "\n"; |
added 9 commits
August 24, 2026 09:48
…works with bagels with fillings!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.