A simple e-commerce system implemented in C++ that allows users to log in as either customers or sellers, perform various actions such as viewing account information, adding products (for sellers), and making purchases (for customers), and features a looped menu for ongoing interactions.
User: The base class for both customers and sellers. It includes common attributes such as username, email, password, and balance. It also has methods for retrieving user information and updating the balance. Customer: Inherits from User and includes additional attributes like the customer's address. It overrides the display_info method to show specific information for customers. Seller: Inherits from User and includes additional attributes such as rating, number of rates, and a vector of sales. Sellers can add sales, display their information, and update their ratings.
Product: Represents a product with attributes such as ID, name, category, price, and the seller. It has a method to display product information.
Database: An abstract base class for database-related classes. Customers_DB, Sellers_DB, Products_DB: Implementations of the database classes for customers, sellers, and products, respectively. They provide methods for adding, finding, and retrieving the size of the stored entities.
seller_ui: Function to handle the seller's user interface, including options for account information, adding products, viewing sales, and logging out. customer_ui: Function to handle the customer's user interface, including options for account information, product search, balance top-up, and logging out.
log_in: Function to handle user login, distinguishing between sellers and customers. It prompts for username and password, checks the credentials, and directs the user to the appropriate interface. create_account: Function to create a new account. It prompts for account type, username, password, email, and additional details (address for customers).
main: The main function initializes the system with some predefined sellers, customers, and products. It then presents a menu for logging in, creating an account, or exiting the program. It contains an infinite loop for user interaction.
The program provides a main menu with options to log in, create an account, or exit. After logging in, users are directed to specific interfaces based on their role (seller or customer). Users can perform various actions, such as viewing account information, adding products (for sellers), searching for products (for customers), making purchases, and logging out.
The program runs in an infinite loop, allowing users to perform multiple actions without restarting. Users can exit the program by selecting the appropriate option from the main menu.