Skip to content

Commit 46b91d8

Browse files
authored
Shopping Mall Management System
Added comprehensive README for Shopping Mall Management System project, detailing features, class diagrams, project structure, and usage instructions.
1 parent 38cba87 commit 46b91d8

File tree

1 file changed

+360
-0
lines changed
  • 1) Object Oriented Design /Shopping Mall Management System

1 file changed

+360
-0
lines changed
Lines changed: 360 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,360 @@
1+
Here’s a complete **GitHub README** and **Java implementation** for a **Shopping Mall Management System** — written in the same professional, structured format as before 👇
2+
3+
---
4+
5+
## 🛍️ GitHub README: Shopping Mall Management System (Java OOP Project)
6+
7+
```markdown
8+
# 🏬 Shopping Mall Management System (Java OOP Project)
9+
10+
A fully object-oriented **Shopping Mall Management System** built in Java that demonstrates real-world modeling using **OOP principles** — encapsulation, inheritance, polymorphism, abstraction, and composition.
11+
12+
This project manages shops, customers, staff, and transactions within a shopping mall.
13+
14+
---
15+
16+
## 🚀 Overview
17+
18+
The system supports:
19+
- Shop registration and management
20+
- Customer registration and purchase handling
21+
- Staff assignment to shops
22+
- Bill generation with discounts and taxes
23+
- Handling invalid or duplicate entries, and out-of-stock items
24+
25+
---
26+
27+
## 🧩 OOP Concepts Applied
28+
29+
| **Concept** | **Example in This System** |
30+
|--------------|-----------------------------|
31+
| **Encapsulation** | Private fields with getters and setters for `Shop`, `Customer`, `Item`, etc. |
32+
| **Inheritance** | `Person` → `Customer`, `Staff` |
33+
| **Polymorphism** | `generateBill()` behaves differently for premium and regular customers |
34+
| **Abstraction** | Abstract class `Person` defines common behavior |
35+
| **Composition** | `Mall` has `List<Shop>`, `List<Customer>`, and `List<Staff>` |
36+
37+
---
38+
39+
## 🧠 Class Diagram (Simplified)
40+
41+
```
42+
43+
Person (abstract)
44+
45+
├── Customer
46+
47+
└── Staff
48+
49+
└── Shop → Mall → Bill
50+
51+
```
52+
53+
---
54+
55+
## 🏗️ Project Structure
56+
57+
```
58+
59+
ShoppingMallManagementSystem.java
60+
├── Person.java
61+
├── Customer.java
62+
├── Staff.java
63+
├── Shop.java
64+
├── Item.java
65+
├── Bill.java (abstract)
66+
├── RegularBill.java
67+
├── PremiumBill.java
68+
└── Mall.java
69+
70+
```
71+
72+
---
73+
74+
## ⚙️ Features
75+
76+
✅ Add and manage shops, staff, and customers
77+
✅ Handle purchases and generate bills
78+
✅ Apply discount logic based on customer type
79+
✅ Prevent duplicate customer registration
80+
✅ Handle out-of-stock item edge cases
81+
82+
---
83+
84+
## 🧾 Example Output
85+
86+
```
87+
88+
✅ Shop registered: Fashion Hub
89+
✅ Customer registered: Riya Sharma (Premium)
90+
✅ Item added: Jeans - ₹2000.0
91+
✅ Item added: T-Shirt - ₹800.0
92+
✅ Purchase successful! Riya Sharma bought Jeans and T-Shirt
93+
Bill for Riya Sharma: ₹2520.0
94+
95+
✅ Customer registered: Aman Verma (Regular)
96+
✅ Purchase successful! Aman Verma bought T-Shirt
97+
Bill for Aman Verma: ₹880.0
98+
99+
❌ Item 'T-Shirt' is out of stock!
100+
⚠️ Customer Aman Verma already exists!
101+
102+
````
103+
104+
---
105+
106+
## 🧪 Edge Cases
107+
108+
| **Scenario** | **Expected Behavior** |
109+
|---------------|------------------------|
110+
| Duplicate customer | Warning message: "⚠️ Customer already exists!" |
111+
| Out-of-stock item | Prints "❌ Item is out of stock!" |
112+
| Invalid purchase | Prints "⚠️ Invalid shop or customer!" |
113+
| Premium discount applied | 10% off total bill + 5% tax |
114+
| Regular customer | No discount + 10% tax |
115+
116+
---
117+
118+
## 🖥️ How to Run
119+
120+
1. Clone the repository:
121+
```bash
122+
git clone https://github.com/<your-username>/ShoppingMallManagementSystem.git
123+
````
124+
125+
2. Compile the Java files:
126+
127+
```bash
128+
javac ShoppingMallManagementSystem.java
129+
```
130+
3. Run the program:
131+
132+
```bash
133+
java ShoppingMallManagementSystem
134+
```
135+
136+
---
137+
138+
## 👨‍💻 Author
139+
140+
**Ankit Majee**
141+
📧 [Email](mailto:your-email@example.com) | 💼 [LinkedIn](https://linkedin.com/in/ankitmajee)
142+
143+
---
144+
145+
## 🏁 License
146+
147+
This project is licensed under the **MIT License** — free to use, modify, and distribute for learning purposes.
148+
149+
---
150+
151+
> ✨ A real-world OOP project simulating a shopping mall’s daily operations using Java.
152+
153+
````
154+
155+
---
156+
157+
## 💻 `ShoppingMallManagementSystem.java` (Full Code)
158+
159+
```java
160+
import java.util.*;
161+
162+
// 🔹 Abstract base class for all people
163+
abstract class Person {
164+
protected String name;
165+
protected String contact;
166+
167+
public Person(String name, String contact) {
168+
this.name = name;
169+
this.contact = contact;
170+
}
171+
172+
public String getName() { return name; }
173+
}
174+
175+
// 🔹 Customer class
176+
class Customer extends Person {
177+
private boolean isPremium;
178+
179+
public Customer(String name, String contact, boolean isPremium) {
180+
super(name, contact);
181+
this.isPremium = isPremium;
182+
}
183+
184+
public boolean isPremium() { return isPremium; }
185+
}
186+
187+
// 🔹 Staff class
188+
class Staff extends Person {
189+
private String role;
190+
191+
public Staff(String name, String contact, String role) {
192+
super(name, contact);
193+
this.role = role;
194+
}
195+
196+
public String getRole() { return role; }
197+
}
198+
199+
// 🔹 Item class
200+
class Item {
201+
private String name;
202+
private double price;
203+
private int stock;
204+
205+
public Item(String name, double price, int stock) {
206+
this.name = name;
207+
this.price = price;
208+
this.stock = stock;
209+
}
210+
211+
public String getName() { return name; }
212+
public double getPrice() { return price; }
213+
public int getStock() { return stock; }
214+
215+
public void reduceStock(int qty) { this.stock -= qty; }
216+
}
217+
218+
// 🔹 Abstract Bill class
219+
abstract class Bill {
220+
protected Customer customer;
221+
protected List<Item> items;
222+
223+
public Bill(Customer customer, List<Item> items) {
224+
this.customer = customer;
225+
this.items = items;
226+
}
227+
228+
public abstract double generateBill();
229+
}
230+
231+
// 🔹 Regular Bill
232+
class RegularBill extends Bill {
233+
public RegularBill(Customer customer, List<Item> items) {
234+
super(customer, items);
235+
}
236+
237+
public double generateBill() {
238+
double total = items.stream().mapToDouble(Item::getPrice).sum();
239+
double tax = total * 0.10;
240+
return total + tax;
241+
}
242+
}
243+
244+
// 🔹 Premium Bill
245+
class PremiumBill extends Bill {
246+
public PremiumBill(Customer customer, List<Item> items) {
247+
super(customer, items);
248+
}
249+
250+
public double generateBill() {
251+
double total = items.stream().mapToDouble(Item::getPrice).sum();
252+
double discount = total * 0.10;
253+
double tax = (total - discount) * 0.05;
254+
return (total - discount) + tax;
255+
}
256+
}
257+
258+
// 🔹 Shop class
259+
class Shop {
260+
private String name;
261+
private List<Item> inventory = new ArrayList<>();
262+
263+
public Shop(String name) {
264+
this.name = name;
265+
}
266+
267+
public String getName() { return name; }
268+
269+
public void addItem(Item item) {
270+
inventory.add(item);
271+
System.out.println("✅ Item added: " + item.getName() + " - ₹" + item.getPrice());
272+
}
273+
274+
public Item findItem(String itemName) {
275+
for (Item i : inventory) {
276+
if (i.getName().equalsIgnoreCase(itemName)) return i;
277+
}
278+
return null;
279+
}
280+
}
281+
282+
// 🔹 Mall class
283+
class Mall {
284+
private List<Shop> shops = new ArrayList<>();
285+
private List<Customer> customers = new ArrayList<>();
286+
287+
public void registerShop(Shop shop) {
288+
shops.add(shop);
289+
System.out.println("✅ Shop registered: " + shop.getName());
290+
}
291+
292+
public void registerCustomer(Customer customer) {
293+
for (Customer c : customers) {
294+
if (c.getName().equalsIgnoreCase(customer.getName())) {
295+
System.out.println("⚠️ Customer " + customer.getName() + " already exists!");
296+
return;
297+
}
298+
}
299+
customers.add(customer);
300+
System.out.println("✅ Customer registered: " + customer.getName() + (customer.isPremium() ? " (Premium)" : " (Regular)"));
301+
}
302+
303+
public void purchase(String customerName, String shopName, List<String> itemNames) {
304+
Customer customer = customers.stream().filter(c -> c.getName().equalsIgnoreCase(customerName)).findFirst().orElse(null);
305+
Shop shop = shops.stream().filter(s -> s.getName().equalsIgnoreCase(shopName)).findFirst().orElse(null);
306+
307+
if (customer == null || shop == null) {
308+
System.out.println("⚠️ Invalid shop or customer!");
309+
return;
310+
}
311+
312+
List<Item> boughtItems = new ArrayList<>();
313+
for (String itemName : itemNames) {
314+
Item item = shop.findItem(itemName);
315+
if (item == null || item.getStock() <= 0) {
316+
System.out.println("❌ Item '" + itemName + "' is out of stock!");
317+
continue;
318+
}
319+
item.reduceStock(1);
320+
boughtItems.add(item);
321+
}
322+
323+
if (!boughtItems.isEmpty()) {
324+
Bill bill = customer.isPremium() ? new PremiumBill(customer, boughtItems) : new RegularBill(customer, boughtItems);
325+
double amount = bill.generateBill();
326+
System.out.println("✅ Purchase successful! " + customer.getName() + " bought " + itemNames);
327+
System.out.println("Bill for " + customer.getName() + ": ₹" + amount);
328+
}
329+
}
330+
}
331+
332+
// 🔹 Main Class
333+
public class ShoppingMallManagementSystem {
334+
public static void main(String[] args) {
335+
Mall mall = new Mall();
336+
337+
// Register shops
338+
Shop fashionHub = new Shop("Fashion Hub");
339+
mall.registerShop(fashionHub);
340+
341+
// Add items
342+
fashionHub.addItem(new Item("Jeans", 2000, 2));
343+
fashionHub.addItem(new Item("T-Shirt", 800, 1));
344+
345+
// Register customers
346+
Customer riya = new Customer("Riya Sharma", "9999999999", true);
347+
mall.registerCustomer(riya);
348+
Customer aman = new Customer("Aman Verma", "8888888888", false);
349+
mall.registerCustomer(aman);
350+
351+
// Make purchases
352+
mall.purchase("Riya Sharma", "Fashion Hub", Arrays.asList("Jeans", "T-Shirt"));
353+
mall.purchase("Aman Verma", "Fashion Hub", Arrays.asList("T-Shirt"));
354+
mall.purchase("Aman Verma", "Fashion Hub", Arrays.asList("T-Shirt")); // Out of stock
355+
mall.registerCustomer(new Customer("Aman Verma", "8888888888", false)); // Duplicate
356+
}
357+
}
358+
````
359+
360+
---

0 commit comments

Comments
 (0)