0% found this document useful (0 votes)
15 views15 pages

report in cpp (3)

The document presents a micro-project report on an 'Online Shopping Management System' developed in C++ as part of the Object Oriented Programming course at Government Polytechnic Pune. It details the system's structure, including classes for Product, Cart, and OnlineShop, and outlines objectives such as simulating online shopping, managing products, and facilitating user interactions. The report concludes that the project effectively applies OOP principles, providing a modular and user-friendly interface for managing shopping functionalities.

Uploaded by

shindegauri384
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views15 pages

report in cpp (3)

The document presents a micro-project report on an 'Online Shopping Management System' developed in C++ as part of the Object Oriented Programming course at Government Polytechnic Pune. It details the system's structure, including classes for Product, Cart, and OnlineShop, and outlines objectives such as simulating online shopping, managing products, and facilitating user interactions. The report concludes that the project effectively applies OOP principles, providing a modular and user-friendly interface for managing shopping functionalities.

Uploaded by

shindegauri384
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as ODT, PDF, TXT or read online on Scribd
You are on page 1/ 15

GOVERNMENT POLYTECHNIC PUNE

(An Autonomous Institute of Maharashtra)

DEPARTMENT OF COMPUTER ENGINEERING


ACADEMIC YEAR : 2024-25

Micro-Project Report on the topic :

"Online Shopping Management System"

Course: Object Oriented Programming

Course Code: CM31203

Guided by:
Smt . B. R. Amrutkar
Lecturer Government Polytechnic Pune

GOVERNMENT POLYTECHNIC PUNE


(An Autonomous Institute of Maharashtra)

1
DEPARTMENT OF COMPUTER ENGINEERING
ACADEMIC YEAR : 2024-25

CERTIFICATE
This is to certify that the micro-project entitled “ Online
Shopping Management System” is bonafide work carried out
by: Anuja Shirole – 2306176 of class Second Year in
partial fulfillment of the requirement for the completion of
course Object Oriented Programming (CM31203) - ODD
2024 of Diploma in Computer Engineering from
Government Polytechnic Pune. The report has been
approved as it satisfies the academic requirements in respect
of micro-project work prescribed for the course.

_____________ _____________ _____________

Prof. B.R Amrutkar Mrs. J.R.Hange Dr. Rajendra K.Patil

(Microproject Guide) (Head of Department) (Principal)

Project Report

Background

2
This code implements a basic Online Shopping System in C++, where users can browse prod-
ucts, add items to their shopping cart, and checkout. The system consists of three main compo-
nents: the Product class, representing individual items; the Cart class, managing the user's se-
lected products and calculating the total price; and the OnlineShop class, which integrates the
product catalog and cart functionality. Users interact through a simple menu, allowing them to
view products, add items to their cart, and complete purchases. The code provides a foundation
for simulating an online shopping experience.

Objectives
The project aims to Online Shopping Management System implement a functional using C++
to manage key operations such as:
1. Simulate an Online Shopping Experience: Provide a basic framework where users can
browse products, add them to a cart, and proceed to checkout.

2. Product Management: Represent products with key attributes (ID, name, price) and dis-
play them to users in a catalog.

3. Shopping Cart Functionality: Allow users to add items to their cart, view the cart's con-
tents, and calculate the total cost of selected items.

4. User Interaction: Create an interactive command-line interface where users can choose
actions such as viewing products, adding to cart, and checking out.

5. Basic Checkout System: Simulate the checkout process by calculating the total price of
items in the cart and displaying a confirmation message upon successful checkout.

Structure Used

Classes and Structure:


1. Product Class:
 id:Unique identifier for the product.
 name: Name of the product.
 price: Price of the product.
 display(): Outputs the product's details to the console.

2. Cart Class :
o Attributes :

 items: A vector (list) that holds Product objects


 addProduct(): Adds a Product to the cart.
 viewCart(): Displays the contents of the cart.
 calculateTotal(): Computes the total price of items in the cart.

3
 checkout(): Displays the total cost of the cart items and checks out.

OnlineShop Class:
Attributes :
 productCatalog: A vector containing available Product objects.
 userCart: A Cart object to store products added by the user.

Methods:
 displayProducts(): Shows all products available in the catalog.
 addToCart(): Adds a product to the cart by its ID.
 viewCart(): Displays the current cart contents.

3. Vectors:
 Used to store collections of objects, specifically products in the catalog and products in
the cart (vector<Product>).
 Methods like push_back() are used to add products to the vectors.

4. Methods:
 display() in Product to print details.
 addProduct(), viewCart(), and checkout() in Cart to manage items.
 addToCart(), viewCart(), and checkout() in OnlineShop to provide user interac-
tion

4. User Interaction Loop (Main Function):

 The main() function presents a menu-driven system allowing users to:

o View products.

o Add products to the cart using product IDs.

o View the cart.

o Checkout.

o Exit the system.

 It uses a do-while loop to keep asking for user input until the user decides to exit.

6. Conditionals and Control Flow:


 switch statement is used to handle user choices (view products, add to cart, etc.).

 Appropriate methods of the OnlineShop class are called based on the user’s choice

7. Basic Input/Output:
 Input: The user enters choices and product IDs.

4
 Output: The system provides feedback like displaying products, confirming cart addi-
tions, and showing the total price at checkout.

Technical Approach :
The technical approach of the Online Shopping System utilizes object-oriented programming
(OOP) principles, structuring the application into distinct classes: Product, Cart, and
OnlineShop. Each class encapsulates relevant attributes and methods to manage products, user
carts, and the shopping process. The system employs std::vector for dynamic storage of
products, allowing easy addition and management of items. A menu-driven interface facilitates
user interaction through a loop that captures choices, using a switch statement to direct actions
like viewing products, adding to the cart, or checking out. This design promotes extensibility and
scalability, enabling future enhancements, such as adding new features or products, while
ensuring code efficiency and maintainability.

Rationale for Key Design Choices

Object-Oriented Approach:
Encapsulation: The design uses separate classes for Product, Cart, and OnlineShop, which en-
capsulates related attributes and behaviors. This separation reduces complexity, as each class
manages its specific responsibilities, making the code easier to understand and maintain.
Abstraction: By utilizing classes, the implementation details are hidden, allowing users to inter-
act with the system through clear, well-defined methods (e.g., addProduct(), viewCart()). This
simplifies the interface and enhances usability.

Class Structure:
 Product Class: This class represents individual items, capturing essential details (ID,
name, price). This structure allows easy management and display of products.
 Cart Class: By separating cart functionality into its own class, the design focuses on
managing user selections, enabling easy modifications to cart operations without affecting
product management.
 OnlineShop Class: This class integrates product management and cart functionality,
serving as the main interface for user interactions, promoting cohesion within the system.

3. Dynamic Data Structures:


 Vectors (std::vector): The choice to use vectors allows for dynamic resizing and efficient
management of product collections. This is crucial for an online shopping system, where
the number of products can vary greatly, facilitating easy addition and retrieval of items.

5
5. Control Flow:
 Switch Statement: Using a switch statement for handling user choices streamlines the
code, making it easy to read and modify. It clearly delineates the possible actions based on
user input, promoting maintainability.

Cos Covered:
• CO1 Understand procedural and object-oriented paradigms.

• CO2 Implement different functions in OOP.

• CO3 Develop programs using classes and objects.

• CO4 Implement programs on inheritance.

• CO6 Develop applications for file handling.

6
Flowchart Chart:

Program :
#include <iostream>

#include <vector>

#include <string>

7
using namespace std;

class Product

public:

int id;

string name;

double price;

Product(int id, string name, double price) : id(id), name(name), price(price) {}

void display() const

cout << "Product ID: " << id << ", Name: " << name << ", Price: $" << price <<
endl;

};

class Cart

private:

vector<Product> items;

public:

void addProduct(const Product& product)

8
{

items.push_back(product);

cout << product.name << " added to cart." << endl;

void viewCart() const

if (items.empty())

cout << "Your cart is empty." << endl;

} else {

cout << "Items in your cart:" << endl;

for (const auto& item : items)

item.display();

double calculateTotal() const

double total = 0;

for (const auto& item : items)

total += item.price;

return total;

9
void checkout() const

if (items.empty())

cout << "Your cart is empty, nothing to checkout!" << endl;

} else {

double total = calculateTotal();

cout << "Your total is: $" << total << endl;

cout << "Thank you for shopping with us!" << endl;

};

class OnlineShop

private:

vector<Product> productCatalog;

Cart userCart;

public:

OnlineShop()

productCatalog.push_back(Product(1, "Laptop", 1200.50));

productCatalog.push_back(Product(2, "Smartphone", 800.99));

productCatalog.push_back(Product(3, "Headphones", 150.75));

productCatalog.push_back(Product(4, "Monitor", 300.40));

10
void displayProducts() const

cout << "Available products:" << endl;

for (const auto& product : productCatalog)

product.display();

void addToCart(int productId)

for (const auto& product : productCatalog)

if (product.id == productId)

userCart.addProduct(product);

return;

cout << "Product with ID " << productId << " not found." << endl;

void viewCart() const

userCart.viewCart();

11
void checkout() const

userCart.checkout();

};

int main()

OnlineShop shop;

int choice;

int productId;

do

cout << "\n--- Online Shopping System ---" << endl;

cout << "1. View Products" << endl;

cout << "2. Add to Cart" << endl;

cout << "3. View Cart" << endl;

cout << "4. Checkout" << endl;

cout << "5. Exit" << endl;

cout << "Enter your choice: ";

cin >> choice;

switch (choice)

case 1:

shop.displayProducts();

break;

case 2:

12
cout << "Enter the Product ID to add to cart: ";

cin >> productId;

shop.addToCart(productId);

break;

case 3:

shop.viewCart();

break;

case 4:

shop.checkout();

break;

case 5:

cout << "Exiting..." << endl;

break;

default:

cout << "Invalid choice! Please try again." << endl;

} while (choice != 5);

return 0;

OUTPUT :

13
Skills Developed :
1. Problem-Solving
2. C++ Programming
3. File Management:
4. Object-Oriented Design

14
5. Debugging and Error Handling
6. File Input/Output Operations
7. Version Control and Code Organization
8. User Interface Design
9. Critical Thinking

Conclusion :

Online Shopping System demonstrates an effective application of object-oriented programming


principles, providing a modular and user-friendly interface for managing products and shopping
cart functionalities. By employing encapsulation and abstraction, the design simplifies code com-
plexity, enhances maintainability, and allows for clear user interactions. The use of dynamic data
structures, specifically vectors, supports efficient management of product catalogs and user carts,
while the menu-driven interface offers an intuitive experience. Overall, this system serves as a
solid foundation for further development, with the flexibility to incorporate additional features
and improvements, ultimately delivering a robust e-commerce solution.

__________________________

15

You might also like