summaryrefslogtreecommitdiff
path: root/oop
diff options
context:
space:
mode:
Diffstat (limited to 'oop')
-rw-r--r--oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java29
-rw-r--r--oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Bill.java16
-rw-r--r--oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/LineItem.java29
3 files changed, 74 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);
+ }
+}
diff --git a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Bill.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Bill.java
new file mode 100644
index 0000000..0c2ff5f
--- /dev/null
+++ b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Bill.java
@@ -0,0 +1,16 @@
+package lk.ac.pdn.ceit.pos.entities;
+
+import java.util.List;
+
+public class Bill {
+ private List<LineItem> lineItems;
+
+ public List<LineItem> getLineItems() {
+ return lineItems;
+ }
+
+ public void setLineItems(List<LineItem> lineItems) {
+ this.lineItems = lineItems;
+ }
+
+}
diff --git a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/LineItem.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/LineItem.java
new file mode 100644
index 0000000..ad6abaf
--- /dev/null
+++ b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/LineItem.java
@@ -0,0 +1,29 @@
+package lk.ac.pdn.ceit.pos.entities;
+
+public class LineItem {
+ private Item item;
+ private int quantity;
+
+ public LineItem(Item item, int quantity) {
+ this.item = item;
+ this.quantity = quantity;
+ }
+
+ public Item getItem() {
+ return item;
+ }
+
+ public void setItem(Item item) {
+ this.item = item;
+ }
+
+ public int getQuantity() {
+ return quantity;
+ }
+
+ public void setQuantity(int quantity) {
+ this.quantity = quantity;
+ }
+
+
+}