Introduction To A Shopping Management System Microproject
Introduction To A Shopping Management System Microproject
Key Objectives:
Product Management: Keep track of the products available for sale, including
their descriptions, prices, and stock quantities.
Inventory Management: Automatically update stock levels when items are sold
and notify when stock is low.
Reports: Generate basic reports, such as total sales, stock levels, and order
histories.
Features:
User Interface: A user-friendly interface to allow customers and administrators
to interact with the system.
Search and Filter: Allow customers to search for products and apply filters (e.g.,
category, price range).
Shopping Cart: Users can add items to their cart, update quantities, or remove
items before checking out.
Order History: Customers can view their previous orders and track the status of
current orders.
Admin Dashboard: Admin users can add new products, update existing ones,
and manage orders and inventory.
// Product class
class Product {
public:
int product_id;
string name;
float price;
int stock;
Product() {}
Product(int id, string n, float p, int s) : product_id(id), name(n), price(p), stock(s) {}
// Customer class
class Customer {
public:
int customer_id;
string name;
Customer() {}
Customer(int id, string n) : customer_id(id), name(n) {}
Order() {}
Order(int id, Customer c) : order_id(id), customer(c) {}
public:
void add_product(int id, string name, float price, int stock) {
products[product_count++] = Product(id, name, price, stock);
cout << "Product added: " << name << endl;
}
void place_order() {
string customer_name;
cout << "Enter customer name: ";
cin >> ws;
getline(cin, customer_name);
if (customer_ptr == nullptr) {
add_customer(customer_name);
customer_ptr = &customers[customer_count - 1];
}
while (true) {
cout << "Enter product ID to add to order (0 to finish): ";
cin >> product_id;
if (product_id == 0) break;
if (product_ptr != nullptr) {
cout << "Enter quantity: ";
cin >> quantity;
if (product_ptr->is_available(quantity)) {
order.add_product(*product_ptr, quantity);
product_ptr->update_stock(quantity);
cout << "Added " << product_ptr->name << " to order." << endl;
} else {
cout << "Not enough stock for " << product_ptr->name << "!" << endl;
}
} else {
cout << "Product not found!" << endl;
}
}
orders[order_count++] = order;
cout << "Order placed successfully!" << endl;
}
void display_orders() {
if (order_count == 0) {
cout << "No orders placed." << endl;
return;
}
void display_products() {
if (product_count == 0) {
cout << "No products available." << endl;
return;
}
cout << "\nAvailable Products:" << endl;
for (int i = 0; i < product_count; ++i) {
products[i].display_info();
}
}
};
// Main functionality
int main() {
ShoppingManagementSystem sms;
// Adding products
sms.add_product(101, "Laptop", 800.00, 10);
sms.add_product(102, "Smartphone", 500.00, 15);
sms.add_product(103, "Headphones", 150.00, 20);
sms.add_product(104, "Tablet", 300.00, 12);
sms.add_product(105, "Smartwatch", 200.00, 8);
sms.add_product(106, "Camera", 700.00, 5);
sms.add_product(107, "Bluetooth Speaker", 120.00, 18);
sms.add_product(108, "Monitor", 220.00, 10);
sms.add_product(109, "Keyboard", 50.00, 30);
sms.add_product(110, "Mouse", 30.00, 50);
sms.add_product(111, "Air Conditioner", 1500.00, 5);
sms.add_product(112, "Refrigerator", 800.00, 7);
sms.add_product(113, "Washing Machine", 500.00, 10);
sms.add_product(114, "Microwave", 250.00, 10);
sms.add_product(115, "Blender", 100.00, 25);
int choice;
cout << "Welcome to the Shopping Management System!" << endl;
while (true) {
cout << "\n1. View Products\n2. Place Order\n3. Display Orders\n4. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
sms.display_products();
break;
case 2:
sms.place_order();
break;
case 3:
sms.display_orders();
break;
case 4:
cout << "Exiting the system. Bye!" << endl;
return 0;
default:
cout << "Invalid option. Please try again." << endl;
}
}
return 0;
}
1. Product Class
Represents a product with details like ID, name, price, and stock.
Methods:
o display_info(): Shows product details.
o is_available(): Checks stock availability.
o update_stock(): Updates stock after an order.
2. Customer Class
3. Order Class
4. ShoppingManagementSystem Class
5. Main Functionality
Key Concepts:
Object-Oriented Programming: Uses classes and objects to organize data and behavior.
Arrays: Used to store products, customers, and orders.
Control Flow: Loops and conditionals handle user input and system operations.
Example Interaction:
User can view products, place orders, and see the total cost of each order.
New customers are added automatically if not found in the system.
Conclusion:
The Shopping Management System microproject provides a practical
learning experience in building a basic but functional retail management
tool. By completing this project, developers can enhance their skills in areas
such as database design, application architecture, and user interface
development, while providing a useful solution to everyday business
operations in a retail or e-commerce setting.