0% found this document useful (0 votes)
6 views

OOP - Section 3D 3O - Assignment 4

Oop project

Uploaded by

70148553
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

OOP - Section 3D 3O - Assignment 4

Oop project

Uploaded by

70148553
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Object Oriented Programming

Section – 2D & 2O
Fall Semester 2024

Course Assignment No. 4


Assignment Date: Tuesday, December 31, 2024
Assigment Deadline: Monday, Januray 06, 2025- 11:59 PM
Instructions:
• You are required to solve the problems presented in this assignment.
• Write clear and well-structured code to solve the problems. Properly comment your
code to explain the logic where necessary.
• Make sure to provide appropriate variable names and input prompts so that the logic of
program and it’s requirements are understood easily.
• Remember to avoid using AI tools to write the entire assignment for you. While you
can seek help from AI tools for guidance, the actual implementation must be your own
work.
Submission Guidelines:
• Prepare a report of solutions to the problem on SLATE (by copy pasting your codes
along with screenshot of output.
• Submit your assignment on or before the specified deadline. Late submissions will be
penalized with a deduction of 1 mark per day.
• Avoid plagiarism and cheating. If AI-generated content or any form of cheating is
detected, you will be penalized with zero marks for the assignment.
Remember, the purpose of this assignment is to assess your programming skills and
understanding of fundamental concepts. Demonstrate your knowledge and problem-solving
capabilities through your own work.

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:

1. Operator Overloading for Product Price Comparison


Customers often compare the prices of two products to choose the most affordable
option. The system must allow comparing two Product objects using the < operator.
This comparison should be based on the product price.
Example:
o If Product A costs $10 and Product B costs $15, then Product A < Product
B should return true.

1. Template Function for Applying Discounts


QuickCart occasionally runs promotions where a discount is applied to individual
products, with flexibility in how the discount is calculated.
You are required to write a template function named calculateDiscountedPrice
that accepts two parameters:
o The original product price (data type can vary, e.g., int, float, or double).
o The discount percentage (data type can vary, e.g., int or float).

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:

• You have a product:


1. Product A: ID = 101, Name = "Apples", Price = $100.50
• Comparing Product A with another product using < should indicate whether it is
cheaper.
• Using the calculateDiscountedPrice function:
o For a price of 100.50 (double) and discount percentage 10 (int), the function
should return 90.45.
o For a price of 100 (int) and discount percentage 15.5 (float), the function
should return 84.5.

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

You might also like