diff options
Diffstat (limited to 'oop')
| -rw-r--r-- | oop/10-point-of-sale/.gitignore | 1 | ||||
| -rw-r--r-- | oop/10-point-of-sale/.vscode/settings.json | 7 | ||||
| -rw-r--r-- | oop/10-point-of-sale/README.md | 18 | ||||
| -rw-r--r-- | oop/10-point-of-sale/docs/01-requirements.txt | 19 | ||||
| -rw-r--r-- | oop/10-point-of-sale/docs/02-analysis-domain-model.png | bin | 150756 -> 0 bytes | |||
| -rw-r--r-- | oop/10-point-of-sale/docs/03-design-class-diagram.png | bin | 45999 -> 0 bytes | |||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/App.java | 16 | ||||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java | 33 | ||||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/TextUI.java | 27 | ||||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Bill.java | 17 | ||||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Item.java | 34 | ||||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/LineItem.java | 29 | ||||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/InMemoryItemManager.java | 43 | ||||
| -rw-r--r-- | oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/ItemManager.java | 11 |
14 files changed, 0 insertions, 255 deletions
diff --git a/oop/10-point-of-sale/.gitignore b/oop/10-point-of-sale/.gitignore deleted file mode 100644 index ba077a4..0000000 --- a/oop/10-point-of-sale/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/oop/10-point-of-sale/.vscode/settings.json b/oop/10-point-of-sale/.vscode/settings.json deleted file mode 100644 index 0ac215c..0000000 --- a/oop/10-point-of-sale/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{
- "java.project.sourcePaths": ["src"],
- "java.project.outputPath": "bin",
- "java.project.referencedLibraries": [
- "lib/**/*.jar"
- ]
-}
diff --git a/oop/10-point-of-sale/README.md b/oop/10-point-of-sale/README.md deleted file mode 100644 index a43b9f6..0000000 --- a/oop/10-point-of-sale/README.md +++ /dev/null @@ -1,18 +0,0 @@ -## Getting Started
-
-Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
-
-## Folder Structure
-
-The workspace contains two folders by default, where:
-
-- `src`: the folder to maintain sources
-- `lib`: the folder to maintain dependencies
-
-Meanwhile, the compiled output files will be generated in the `bin` folder by default.
-
-> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
-
-## Dependency Management
-
-The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
diff --git a/oop/10-point-of-sale/docs/01-requirements.txt b/oop/10-point-of-sale/docs/01-requirements.txt deleted file mode 100644 index 86e497a..0000000 --- a/oop/10-point-of-sale/docs/01-requirements.txt +++ /dev/null @@ -1,19 +0,0 @@ -A POS needs to be created. A customer would come to the cashier and the cashier would take items from the cart and enter the item ids to the system. The system would ask the number of items to be purchased. The system would create a bill and add line items to it. At the end, the total should be calculated and the tax should be added. The system would ask to enter the amount of money the customer would give. The system should print the entire bill with the balance to be given back to the customer. - -POS (system) - -Customer - -Cashier - -Item - itemId - -LineItem - quantity - -Bill - total - taxAmount - moneyGivenByCustomer - balanceToBeGivenToCustomer diff --git a/oop/10-point-of-sale/docs/02-analysis-domain-model.png b/oop/10-point-of-sale/docs/02-analysis-domain-model.png Binary files differdeleted file mode 100644 index 26396e4..0000000 --- a/oop/10-point-of-sale/docs/02-analysis-domain-model.png +++ /dev/null diff --git a/oop/10-point-of-sale/docs/03-design-class-diagram.png b/oop/10-point-of-sale/docs/03-design-class-diagram.png Binary files differdeleted file mode 100644 index c4da864..0000000 --- a/oop/10-point-of-sale/docs/03-design-class-diagram.png +++ /dev/null diff --git a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/App.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/App.java deleted file mode 100644 index c3f1037..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/App.java +++ /dev/null @@ -1,16 +0,0 @@ -package lk.ac.pdn.ceit.pos;
-
-import lk.ac.pdn.ceit.pos.item.InMemoryItemManager;
-import lk.ac.pdn.ceit.pos.item.ItemManager;
-
-public class App {
- public static void main(String[] args) throws Exception {
- ItemManager itemManager = new InMemoryItemManager();
-
- PointOfSale pos = new PointOfSale(itemManager);
-
- TextUI ui = new TextUI(pos);
-
- ui.start();
- }
-}
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 deleted file mode 100644 index dfac6e1..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/PointOfSale.java +++ /dev/null @@ -1,33 +0,0 @@ -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 PointOfSale(ItemManager itemManager) { - this.itemManager = itemManager; - } - - 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/TextUI.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/TextUI.java deleted file mode 100644 index 056e41e..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/TextUI.java +++ /dev/null @@ -1,27 +0,0 @@ -package lk.ac.pdn.ceit.pos; - -import lk.ac.pdn.ceit.pos.entities.Bill; - -public class TextUI { - private PointOfSale pos; - - public TextUI(PointOfSale pos) { - this.pos = pos; - } - - public void start() { - IO.println("POS Started."); - - // Assume a bill should be created. - Bill bill = pos.createNewBill(); - - // Assume: Create a line item - pos.addLineItem("F001", 2); - - pos.addLineItem("F002", 3); - - // ... - - // Print bill - } -} 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 deleted file mode 100644 index ad6a87e..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Bill.java +++ /dev/null @@ -1,17 +0,0 @@ -package lk.ac.pdn.ceit.pos.entities; - -import java.util.ArrayList; -import java.util.List; - -public class Bill { - private List<LineItem> lineItems = new ArrayList<>(); - - 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/Item.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Item.java deleted file mode 100644 index 47b8e32..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/Item.java +++ /dev/null @@ -1,34 +0,0 @@ -package lk.ac.pdn.ceit.pos.entities; - -public class Item { - private String name; - private String id; - private double unitPrice; - - public Item(String name, String id, double unitPrice) { - this.name = name; - this.id = id; - this.unitPrice = unitPrice; - } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - } - public String getId() { - return id; - } - public void setId(String id) { - this.id = id; - } - public double getUnitPrice() { - return unitPrice; - } - public void setUnitPrice(double unitPrice) { - this.unitPrice = unitPrice; - } - - -} 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 deleted file mode 100644 index ad6abaf..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/entities/LineItem.java +++ /dev/null @@ -1,29 +0,0 @@ -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; - } - - -} 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 deleted file mode 100644 index 00bc835..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/InMemoryItemManager.java +++ /dev/null @@ -1,43 +0,0 @@ -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; - } - -} diff --git a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/ItemManager.java b/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/ItemManager.java deleted file mode 100644 index 5c6b47e..0000000 --- a/oop/10-point-of-sale/src/lk/ac/pdn/ceit/pos/item/ItemManager.java +++ /dev/null @@ -1,11 +0,0 @@ -package lk.ac.pdn.ceit.pos.item; - -import java.util.List; - -import lk.ac.pdn.ceit.pos.entities.Item; - -public interface ItemManager { - public Item findById(String id); - public List<Item> searchByName(String word); - public Item create(String name, String id, double unitPrice); -} |
