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

Code Documentation for Task 1 and Task 2 pdf

Uploaded by

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

Code Documentation for Task 1 and Task 2 pdf

Uploaded by

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

Code Documentation for Task 1 and Task 2

Task 1: StringProcessor Class

The StringProcessor class in Python processes string operations in a sequential order using a
queue implemented with collections.deque. This approach ensures that operations are
handled in a First-In-First-Out (FIFO) manner, which aligns with the natural order of the input.
The queue is initialized with a list of operations, where the first element is the starting string,
followed by alternating operators (+ or -) and operands. Concatenation (+) appends the operand
string to the result, while subtraction (-) removes all occurrences of characters in the operand
from the result using Python’s string replacement method. The program demonstrates its
functionality with several test cases, showcasing di erent combinations of operations, such as
adding substrings, removing specific characters, and modifying complex strings. This design
e ectively handles a variety of scenarios while maintaining clarity and e iciency.

Task 2: OnlineStore Class

The OnlineStore class in C++ is a robust implementation of an online store’s purchase


management system using a linked list. Each purchase is represented as a node containing
customer information (ID, name), the purchased item, the purchase date, and a pointer to the
next node. The class maintains three separate linked lists: current purchases, processed
purchases, and returned purchases, allowing dynamic organization of orders based on their
status. Key features include adding purchases to the current list, sorting purchases by customer
ID using bubble sort, and transferring purchases between categories (e.g., returning a purchase
or marking it as processed). The class also provides functionality to search for all purchases by
a specific customer ID and displays the current state of all purchase lists. By combining
dynamic memory management, linked list traversal, and sorting algorithms, the OnlineStore
class emulates the workflow of a real-world e-commerce platform, demonstrating object-
oriented design principles like encapsulation and modularity

You might also like