From 3920d7b7abeec14b76b310b7f15fc4862347fa61 Mon Sep 17 00:00:00 2001 From: Jamila642 <20220642@nileuniversity.edu.ng> Date: Thu, 15 May 2025 18:00:52 +0100 Subject: [PATCH 1/2] Add files via upload --- InventoryApp 2.zip | Bin 0 -> 8076 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 InventoryApp 2.zip diff --git a/InventoryApp 2.zip b/InventoryApp 2.zip new file mode 100644 index 0000000000000000000000000000000000000000..b0d15c44ec0bfa491b834b246d569f684074c538 GIT binary patch literal 8076 zcmdT|c|6qX7alu9mW*YREm^W}ajhAWJ?J9FMs_1jSj#C z&~o>MxqEwf20-9&E=e&Te`){`>3bpo;LB%BjCTPjni%*TzrGB<1fv8{eisak31(@j z2T{|99v2g}+#GkOuwiU`jDh=*lhB8KOl6HC zj_2lv81QM{r{PLeg*Hdgv*`8o4(SLBv}+9s3F`@KcL_b{(t!z}WyMRxt7OW>C8eZw zrAujhHH8oO3Ja9j0{{j(6qN3!>%1@w{W8q!FD|rKb2bUX`n@nl>X5^F>Y{FT_^1dk zvpVu(Xkb+eHtBX}lcTBch0@PwJ^&2x9Py|qyypp|M}#5{*gDTXod}S4E{Ck&y}~*N7GbruSwK%{XGI@~9+v&8kMf zoDAi=69J?{k-VcU$DlHl{T&v4)#}}1_IU~Jk*vmKE8f{qk%Qz&i53X(M6g+XTX(-_ zK(Ow*Tyd;%i%Q5PJCc2Nbuc+uqv}QzM(VD2CoTnCU)u#^G=x92@J_ht3Z75D5GQ#z zf5>O5hWNHReE64zJcpx*GydmQ;`Y-f-SZsmLK|tb%E4oVLq?Q^UWMCi#gQo*B7a~@F8tJl(A%f zf5LkQjZ;*!EkBl74sc<_-MG=vix!j$u!&!nnI6d_;gW{;d zbiRl5zH{)mP})XI-`TOGm?!1UoroxevZ=?KbViTpl!=8yQBvE*<@nnTC56x$=nJT% z>z<}jU?T0VpdP>cNUeBn9zd5~JZMq*yp_uDct=k_B0hSD;OffNSzEF+9(OoN}S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^^`bD!Skn zT*3PfDkU{*e9#iqUG1I!Xd;}$=%pE&Jazt}4qP=LsC3EI&rUYHtu3v|A7nF9VCh3{ zaFga4?+o)jlCvHG@#%^}yMr8_@Cb)rGci+uXliYwb3ZoAcdA`79)z8@a^>pJTcz0x z{9N1riax9K^3g@%ckDq2?s^Usj${V-e)cWsL65r#+(Mxnp4H#+V@#&aU!=p;E%46i#ET zGa_V52eb+T9xfbR%qkWgV>S^YDTQR+tqMO^e`x)sk5_LwaV@m7*Y!}zy|UCnMVSZ= z_+!hl*wRWxWRu>)@7I&xoD!uAOG$B%ra%RTG_l_s6>w(Y07AWW4wJpp9;R~nWapp< zE{IrjOV;l{ibAH)WE46*F-rsCU{1RDW*bVEb^hd;7yq{0CymtV z8X?$UxYGrn(@h2-!fv+)I)4WJ>T%;b#$W(WP=p>PDB+Gbp77XR9oMpA#R;E{026(e z^Y-2pCOURK$4wp^9XENNP0>G);v~OCnw?CrEkIadzjvbkQt2(E8?&o!iI3Np!lMs1 zFfIdj90qR@9OOGOz~@hGfxwqL3oZm?76XANcf6L-mf-lxhZ{FILJhMhd@CP3DEO_T zEim{vY=VKXP;Se?X?r(k3k*IsLYvt5VqkV+^CMSh3m`sT{J4M+V=4l8ZDX`-0mH{m z0v8N%7X$Vqc7Lh4o#C3Ksu!Nvu z#}MwlRSE|+8}R~zil_EBdyRj7i#uLWF?4@4|CBcY|FP?5=n`~E-X;g!i^0K7IkeLf zO#Yij_)p_)pmB$%$|h(phQCAq?`46zr^s%~!hSa)0$}U=8}hbS0|F#a-2^_#^ivXG bvmj(K`j!V7=I{UjK$xF2%xoNC#{Ty|fKY+! literal 0 HcmV?d00001 From 11cf103a016e2b2599c01dd63cc02d4af623676c Mon Sep 17 00:00:00 2001 From: Jamila642 <20220642@nileuniversity.edu.ng> Date: Fri, 16 May 2025 14:07:01 +0200 Subject: [PATCH 2/2] Add files via upload --- .../InventoryApp 2/InventoryApp 2/README.md | 74 ++++++++++++++++++ .../src/com/inventory/main/InventoryApp.java | 75 +++++++++++++++++++ .../src/com/inventory/model/Inventory.java | 71 ++++++++++++++++++ .../src/com/inventory/model/Product.java | 62 +++++++++++++++ 4 files changed, 282 insertions(+) create mode 100644 JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/README.md create mode 100644 JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/main/InventoryApp.java create mode 100644 JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Inventory.java create mode 100644 JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Product.java diff --git a/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/README.md b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/README.md new file mode 100644 index 0000000..75e3d43 --- /dev/null +++ b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/README.md @@ -0,0 +1,74 @@ +# Inventory Management System Application + +**Authors:** +- Jamila Mato (ID: 20220642) +- Haseena Abdullahi (ID: 20220600) + +**Course:** Object-Oriented Programming + +## Project Description + +This is a simple Java console application that simulates an Inventory Management System. It allows users to: + +- Add new products +- View the entire inventory +- Update stock levels +- Delete products + +The system is designed using **Object-Oriented Programming (OOP)** principles such as: + +- **Encapsulation:** Each product's data is kept private within the `Product` class with access provided through getter/setter methods. +- **Association:** The `Inventory` class maintains a collection (list) of `Product` objects and operates on them. +- **Modularity:** Classes are organized by purpose and package to enhance readability and maintainability. + +## Project Structure + +``` +InventoryApp/ +├── src/ +│ └── com/ +│ └── inventory/ +│ ├── model/ +│ │ ├── Product.java +│ │ └── Inventory.java +│ └── main/ +│ └── InventoryApp.java +└── README.md +``` + +## How to Compile and Run + +### 1. Open Terminal or Command Prompt. + +### 2. Navigate to the `src` directory of the project: +```bash +cd path/to/InventoryApp/src +``` + +### 3. Compile all Java files: +```bash +javac com/inventory/model/*.java com/inventory/main/InventoryApp.java +``` + +### 4. Run the application: +```bash +java com.inventory.main.InventoryApp +``` + +## Example Use + +```text +=== Inventory Management System === +1. Add New Product +2. View Inventory +3. Update Stock +4. Delete Product +5. Exit +Choose an option (1-5): +``` + +## Notes + +- Input validation is included to handle invalid numeric input. +- Stock updates prevent negative values. +- Product IDs must be unique. \ No newline at end of file diff --git a/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/main/InventoryApp.java b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/main/InventoryApp.java new file mode 100644 index 0000000..61d06e4 --- /dev/null +++ b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/main/InventoryApp.java @@ -0,0 +1,75 @@ +package com.inventory.main; + +import com.inventory.model.Inventory; +import com.inventory.model.Product; + +import java.util.Scanner; + +public class InventoryApp { + public static void main(String[] args) { + Inventory inventory = new Inventory(); + Scanner scanner = new Scanner(System.in); + boolean running = true; + + while (running) { + System.out.println("\n=== Inventory Management System ==="); + System.out.println("1. Add New Product"); + System.out.println("2. View Inventory"); + System.out.println("3. Update Stock"); + System.out.println("4. Delete Product"); + System.out.println("5. Exit"); + System.out.print("Choose an option (1-5): "); + + try { + int choice = Integer.parseInt(scanner.nextLine()); + switch (choice) { + case 1: + System.out.print("Enter Product ID: "); + String id = scanner.nextLine(); + System.out.print("Enter Product Name: "); + String name = scanner.nextLine(); + System.out.print("Enter Product Description: "); + String desc = scanner.nextLine(); + System.out.print("Enter Product Price: "); + double price = Double.parseDouble(scanner.nextLine()); + System.out.print("Enter Initial Stock Quantity: "); + int qty = Integer.parseInt(scanner.nextLine()); + + Product product = new Product(id, name, desc, price, qty); + inventory.addProduct(product); + break; + + case 2: + inventory.displayInventory(); + break; + + case 3: + System.out.print("Enter Product ID: "); + String updateId = scanner.nextLine(); + System.out.print("Enter Quantity Change (positive to add, negative to remove): "); + int change = Integer.parseInt(scanner.nextLine()); + inventory.updateStock(updateId, change); + break; + + case 4: + System.out.print("Enter Product ID to delete: "); + String deleteId = scanner.nextLine(); + inventory.deleteProduct(deleteId); + break; + + case 5: + running = false; + System.out.println("Exiting the application..."); + break; + + default: + System.out.println("Invalid option. Please choose between 1-5."); + } + } catch (NumberFormatException e) { + System.out.println("Invalid input. Please enter the correct data type."); + } + } + + scanner.close(); + } +} \ No newline at end of file diff --git a/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Inventory.java b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Inventory.java new file mode 100644 index 0000000..7b4dfa7 --- /dev/null +++ b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Inventory.java @@ -0,0 +1,71 @@ +package com.inventory.model; + +import java.util.ArrayList; +import java.util.List; + +public class Inventory { + private List products; + + public Inventory() { + products = new ArrayList<>(); + } + + public void addProduct(Product product) { + for (Product p : products) { + if (p.getProductId().equalsIgnoreCase(product.getProductId())) { + System.out.println("Product with ID " + product.getProductId() + " already exists."); + return; + } + } + products.add(product); + System.out.println("Product added successfully."); + } + + public Product getProductById(String productId) { + for (Product p : products) { + if (p.getProductId().equalsIgnoreCase(productId)) { + return p; + } + } + return null; + } + + public List getAllProducts() { + return products; + } + + public void updateStock(String productId, int quantityChange) { + Product p = getProductById(productId); + if (p != null) { + int newQuantity = p.getStockQuantity() + quantityChange; + if (newQuantity < 0) { + System.out.println("Cannot reduce stock below 0."); + } else { + p.setStockQuantity(newQuantity); + System.out.println("Stock updated successfully."); + } + } else { + System.out.println("Product not found."); + } + } + + public void deleteProduct(String productId) { + Product p = getProductById(productId); + if (p != null) { + products.remove(p); + System.out.println("Product deleted successfully."); + } else { + System.out.println("Product not found."); + } + } + + public void displayInventory() { + if (products.isEmpty()) { + System.out.println("Inventory is empty."); + } else { + for (Product p : products) { + System.out.println(p); + } + } + } +} \ No newline at end of file diff --git a/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Product.java b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Product.java new file mode 100644 index 0000000..bb9eb82 --- /dev/null +++ b/JAMILA KABIR MATO 20220642 HASEENA ABDULLAHI SADIQ 20220600/InventoryApp 2/InventoryApp 2/src/com/inventory/model/Product.java @@ -0,0 +1,62 @@ +package com.inventory.model; + +public class Product { + private String productId; + private String name; + private String description; + private double price; + private int stockQuantity; + + public Product(String productId, String name, String description, double price, int stockQuantity) { + this.productId = productId; + this.name = name; + this.description = description; + this.price = price; + this.stockQuantity = stockQuantity; + } + + public String getProductId() { + return productId; + } + + public String getName() { + return name; + } + + public String getDescription() { + return description; + } + + public double getPrice() { + return price; + } + + public int getStockQuantity() { + return stockQuantity; + } + + public void setName(String name) { + this.name = name; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setPrice(double price) { + this.price = price; + } + + public void setStockQuantity(int stockQuantity) { + this.stockQuantity = stockQuantity; + } + + @Override + public String toString() { + return "Product ID: " + productId + + ", Name: " + name + + ", Description: " + description + + ", Price: $" + price + + ", Stock Quantity: " + stockQuantity; + } +} \ No newline at end of file