From ba8173de256d117f6936b9dffba2eb44247926df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D9=85=D9=87=D9=86=D8=AF=20=D8=AF=D8=B1=D9=88=D9=8A=D8=B4?= Date: Sat, 11 Oct 2025 14:53:12 +0000 Subject: [PATCH] =?UTF-8?q?=D8=B1=D9=81=D8=B9=20=D8=A7=D9=84=D9=85=D9=84?= =?UTF-8?q?=D9=81=D8=A7=D8=AA=20=D8=A5=D9=84=D9=89=20"/"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Customer.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++ Order.java | 42 +++++++++++++++++++++++++++++++++++++ Product.java | 44 ++++++++++++++++++++++++++++++++++++++ README.md | 4 ++++ 4 files changed, 148 insertions(+) create mode 100644 Customer.java create mode 100644 Order.java create mode 100644 Product.java create mode 100644 README.md diff --git a/Customer.java b/Customer.java new file mode 100644 index 0000000..e9247c7 --- /dev/null +++ b/Customer.java @@ -0,0 +1,58 @@ +package com.ecommerce; + +import java.util.ArrayList; + +public class Customer { + // id counter used to make the id increases each time there is more customer had added + private static int idCounter = 0; + // id variable is the id + private int id; + private String name; + private ArrayList shoppingCart; + + + public Customer(String name){ + + idCounter++; + setName(name); + shoppingCart = new ArrayList<>(); + id = idCounter; + } + + + public int getId() { + return id; + } + + + + public String getName() { + return name; + } + + public void setName(String name) { + if(isAlpha(name)) { + this.name = name; + } + } + + + public ArrayList getShoppingCart() { + return shoppingCart; + } + + // to add the product to the customer's shopping cart + public void addToShoppingCart(Product product) { + this.shoppingCart.add(product); + } + + + public static boolean isAlpha(String n){ + for(int i = 0; i products){ + double totalAmount = 0; + for(Product i : products){ + totalAmount = totalAmount + i.getPrice(); + } + return totalAmount; + } + +} diff --git a/Product.java b/Product.java new file mode 100644 index 0000000..f132afb --- /dev/null +++ b/Product.java @@ -0,0 +1,44 @@ +package com.ecommerce; + + +public class Product { + // id variable is the id + private int id; + // id counter used to make the id increases each time there is more products had added + private static int idCounter = 0; + private String name; + private double price; + + + public Product(String name, double price) { + idCounter++; + setName(name); + setPrice(price); + this.id = idCounter; + } + + + public double getPrice() { + return price; + } + + public void setPrice(double price) { + if(price > 0) { + this.price = price; + } + } + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + + public int getId() { + return id; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..c2a782b --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Simple-Online-Store +A Simple Online Store App that built with Java + +Developed a simple sales management application in Java that displays the product list, allows products to be added to the shopping cart, and calculates the grand total of the invoice. The Application runs via the command line and interacts with the user using the products ID. The project reflects my skills in programming and designing small applications