summaryrefslogtreecommitdiff
path: root/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-03-15 16:33:18 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-03-15 16:33:18 +0530
commitee94d753a9f87d0b46b3aad3d3cf855056562ad2 (patch)
treef5673b4b806e92b1d98f1167700d49535bea8338 /oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item
parent7c40224d014257f9112da2ffceda3a357beb69a9 (diff)
Additional classes related to POS.
Diffstat (limited to 'oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item')
-rw-r--r--oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/InMemoryItemManager.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/InMemoryItemManager.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/InMemoryItemManager.java
new file mode 100644
index 0000000..00bc835
--- /dev/null
+++ b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/InMemoryItemManager.java
@@ -0,0 +1,43 @@
+package lk.ac.pdn.ceit.pos.item;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import lk.ac.pdn.ceit.pos.entities.Item;
+
+public class InMemoryItemManager implements ItemManager {
+
+ // Assume this is the item storage
+ private Map<String, Item> items = new HashMap<>();
+
+ // Initial set of data for demo purposes
+ public InMemoryItemManager() {
+ this.create("Dhal", "F001", 300.00);
+ this.create("Bread", "F002", 180.00);
+ this.create("Sunlight Soap", "S001", 150.00);
+ }
+
+ @Override
+ public Item findById(String id) {
+ return items.get(id);
+ }
+
+ @Override
+ public List<Item> searchByName(String word) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException("Unimplemented method 'searchByName'");
+ }
+
+ @Override
+ public Item create(String name, String id, double unitPrice) {
+ // Create a new Item
+ Item item = new Item(name, id, unitPrice);
+
+ // Add to storage
+ items.put(id, item);
+
+ return item;
+ }
+
+}