NexTrend E-Commerce
NexTrend E-Commerce
Output:
Source Code (For User-Input):
Output:
Description
E-commerce Product Catalog:
Domain: Retail and E-commerce
Hierarchy: Category > Subcategory > Product > Variant
Objects: Products can have attributes like price, description, and stock level.
Overview
The code represents a simple e-commerce product catalog system. It defines a base class
Product and two subclasses, Electronics and Clothing, to represent different types of products.
The main class, ECommerceCatalog, demonstrates how to create and display a list of products.
Class Breakdown
1. Product Class
- Attributes:
- name: The name of the product.
- price: The price of the product in Philippine Pesos.
- stockLevel: The current stock level of the product.
- description: A description of the product.
- Constructor: Initializes the product's attributes.
- Methods:
- displayProductInfo(): Displays the product's details, including name, price, stock level, and
description.
- updateStock(int quantity): Updates the stock level by adding the specified quantity and
prints the updated stock level.
2. Electronics Class
- Inherits from: Product
- Additional Attribute:
- warrantyPeriod: The warranty period for the electronic product.
- Constructor: Initializes the electronics-specific attributes and calls the superclass constructor
to set common attributes.
- Method:
- displayElectronicsInfo(): Displays the product's details along with the warranty period by
calling the displayProductInfo() method from the `Product` class.
3. Clothing Class
- Inherits from: Product
- Additional Attribute:
- size: The size of the clothing item.
- Constructor: Initializes the clothing-specific attributes and calls the superclass constructor to
set common attributes.
- Method:
- displayClothingInfo(): Displays the product's details along with the size by calling the
displayProductInfo() method from the `Product` class.
- Product is the base class that contains common attributes and methods for all products.
- Electronics and Clothing are subclasses that inherit from the Product class.
- Each subclass has its own specific attributes and methods in addition to those inherited from the
Product class.