Description
Assignment Question:
You are tasked with developing a comprehensive and advanced billing system for a retail store using Java. This system should demonstrate the effective use of object-oriented principles, particularly inheritance, to manage various product categories and their unique attributes. Your implementation should include the following features:
-
Base Class -
Product
:- Design a base class
Product
with the following attributes:String productID
: A unique identifier for each product.String name
: The name of the product.double price
: The base price of the product.int quantity
: The quantity of the product available.
- Implement methods in the
Product
class to:- Display product details.
- Calculate the total price for the specified quantity of the product.
- Design a base class
-
Derived Classes - Specialized Products:
- Create three subclasses of
Product
, each representing a different product category. Each subclass should override thecalculatePrice
method to include specific pricing logic:- PerishableProduct:
- Attributes:
String expiryDate
,double discount
. - The price should include a discount based on how close the product is to its expiry date.
- Attributes:
- ElectronicsProduct:
- Attributes:
int warrantyPeriod
,String brand
. - The price should include any additional warranty charges.
- Attributes:
- ClothingProduct:
- Attributes:
String size
,String material
. - The price should reflect any seasonal discounts.
- Attributes:
- PerishableProduct:
- Create three subclasses of
-
Discount Mechanism:
- Implement a
Discount
interface with a method to apply discounts to the product price. Ensure that each derived product class implements this interface, allowing for custom discount logic based on product attributes.
- Implement a
-
Billing System:
- Develop a
BillingSystem
class that:- Manages a list of
Product
objects. - Allows adding, removing, and viewing products in the billing list.
- Computes the total bill by summing up the individual product prices, taking into account any discounts.
- Manages a list of
- Develop a
-
User Interface -
BillingSystemApp
:- Create a user interface class,
BillingSystemApp
, that:- Interacts with the user to add products to the billing system.
- Displays the current billing list.
- Calculates and prints the final bill amount.
- Create a user interface class,
-
Advanced Features (Optional):
- Implement file handling capabilities to:
- Save the billing details to a file.
- Load billing details from a file.
- Include sorting functionality to organize products in the billing list by price, name, or category.
- Allow the user to update product details (e.g., change the quantity, apply a new discount).
- Implement file handling capabilities to:
Objective:
By completing this assignment, you will demonstrate your ability to design and implement a complex system using inheritance and polymorphism in Java. This system should be flexible, allowing for future expansion, such as adding new product categories or discount types, without significant changes to the existing codebase.