summaryrefslogtreecommitdiff
path: root/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java
diff options
context:
space:
mode:
authorKamal Wickramanayake <kamal@inbox.lk>2026-03-15 15:41:09 +0530
committerKamal Wickramanayake <kamal@inbox.lk>2026-03-15 15:41:09 +0530
commit11d647bd802e014bc941ebda7889fe9978807478 (patch)
tree6a23c7227449f3cd598b871b8e9950f94593ae1f /oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java
parent3528a4df53a8ee93a1948bdd41825d8464ef9f78 (diff)
Added Bill, PointOfSale, LineItem to OOP sample application
Diffstat (limited to 'oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java')
-rw-r--r--oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java
new file mode 100644
index 0000000..990a635
--- /dev/null
+++ b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java
@@ -0,0 +1,29 @@
+package lk.ac.pdn.ceit.pos;
+
+import lk.ac.pdn.ceit.pos.entities.Bill;
+import lk.ac.pdn.ceit.pos.entities.Item;
+import lk.ac.pdn.ceit.pos.entities.LineItem;
+import lk.ac.pdn.ceit.pos.item.ItemManager;
+
+public class PointOfSale {
+
+ private ItemManager itemManager;
+
+ private Bill bill;
+
+ public Bill createNewBill() {
+ bill = new Bill();
+ return bill;
+ }
+
+ public void addLineItem(String itemId, int quantity) {
+ // From the ItemManager, get the Item.
+ Item item = itemManager.findById(itemId);
+
+ // Create a new LineItem and associate it with the item returned
+ LineItem lineItem = new LineItem(item, quantity);
+
+ // Add the new LineItem to the bill
+ bill.getLineItems().add(lineItem);
+ }
+}