OOP - Section 3D 3O - Assignment 4
OOP - Section 3D 3O - Assignment 4
Section – 2D & 2O
Fall Semester 2024
Page 1 of 3
QuickCart
In a bustling urban city, a new grocery delivery startup called QuickCart is gaining popularity
for its efficiency in delivering groceries within minutes. To enhance customer experience, the
company is working on improving its backend systems to simplify common tasks like
comparing product prices and managing discounts. The developers are tasked with creating a
robust, reusable component for managing some of these operations programmatically.
You are a part of the developers team and the company wants you to design a simple class that
represents a Product. Each product has a unique ID, a name, and a price. It should perform the
following functionalities:
Requirements:
The function should return the final price after applying the discount. The function must
handle the different data types for the price and the discount percentage seamlessly.
Example:
o If the price is 100.50 (as a double) and the discount percentage is 10 (as an
int), the result should be 90.45.
o If the price is 100 (as an int) and the discount percentage is 15.5 (as a float),
the result should be 84.5.
Constraints:
• The class should have member variables for the product ID, name, and price.
• The < operator should only compare prices and not other attributes.
• The calculateDiscountedPrice template function should properly handle mixed
data types for the two parameters and return the correct discounted price.
• Proper encapsulation and use of member functions are encouraged.
• Provide clear documentation within the code for each function and class member.
Page 2 of 3
Example Use Case:
This task is part of the broader effort to make QuickCart’s backend system more modular and
user-friendly, ensuring smooth operations and happier customers.
Page 3 of 3