OOPS File
OOPS File
NEW DELHI
PROJECT-BASED LEARNING
Stock Management System
#include <vector>
#include <string>
#include <map>
#include <algorithm>
class Product
public:
int stockQuantity;
Product(string n, string sku, string cat, string sup, double c, double sp, int sq)
cout << "SKU: " << SKU << " | Name: " << setw(10) << name
<< " | Category: " << setw(10) << category << " | Stock Quantity: "
if (stockQuantity < 5)
};
class StockManagementSystem
{
private:
vector<Product> products;
public:
void dashboard()
int totalStock = 0;
totalStock += p.stockQuantity;
if (p.stockQuantity < 5)
alerts[p.SKU].push_back("Low stock");
if (p.stockQuantity < 5)
cout << "- SKU: " << p.SKU << " (Item: " << p.name << ") - Low Stock Alert (Quantity: "
void addProduct()
int stockQuantity;
cout << "\n--- Add Product ---\n";
void updateProduct()
string sku;
if (p.SKU == sku)
cout << "\nUpdating Product Details for SKU: " << sku << endl;
cout << "Enter new category (current: " << p.category << "): ";
cout << "Enter new supplier (current: " << p.supplier << "): ";
cout << "Enter new cost (current: $" << p.cost << "): ";
cout << "Enter new selling price (current: $" << p.sellingPrice << "): ";
cout << "Enter new stock quantity (current: " << p.stockQuantity << "): ";
return;
void deleteProduct()
string sku;
if (it != products.end())
cout << "\nAre you sure you want to delete product " << sku << "? (y/n): ";
char confirm;
if (confirm == 'y')
{
products.erase(it, products.end());
else
else
void viewStockLevels()
p.display();
void createOrder()
string sku;
int quantity;
if (p.SKU == sku)
p.stockQuantity -= quantity;
cout << "Remaining stock for " << p.name << " (SKU: " << sku << "): " << p.stockQuantity << "\n";
else
cout << "Insufficient stock! Only " << p.stockQuantity << " available.\n";
return;
void viewOrderHistory()
void generateInvoice()
void run()
while (true)
cout << "1. Dashboard\n2. Add Product\n3. Update Product\n4. Delete Product\n";
cout << "5. View Stock Levels\n6. Create Order\n7. View Order History\n8. Generate Invoice\n9. Exit\n";
int choice;
switch (choice)
case 1:
dashboard();
break;
case 2:
addProduct();
break;
case 3:
updateProduct();
break;
case 4:
deleteProduct();
break;
case 5:
viewStockLevels();
break;
case 6:
createOrder();
break;
case 7:
viewOrderHistory();
break;
case 8:
generateInvoice();
break;
case 9:
return;
default:
};
int main()
StockManagementSystem sms;
sms.run();
return 0;
}
OUTPUT
Dashboard:
Add Product:
Update Product:
Delete Product:
View Stock Levels:
Create Order:
View Order History:
Generate Invoice: