Order processing with delegates for filtering and sorting
C#
Medium
delegates
Task «Order processing with delegates for filtering and sorting»
Implement a program for processing a list of orders. You have an Order class with fields Id (int), CustomerName (string), Amount (decimal), and Status (string: "Pending", "Shipped", "Delivered"). In Main, create a list of 5 orders. Use the Func<Order, bool> delegate for filtering orders by status and the Comparison<Order> delegate for sorting by amount (ascending). Write a ProcessOrders method that takes a list, a filter delegate, and a comparison delegate, applies the filter, sorts the result, and outputs the filtered orders in the format "Id: X, Customer: Y, Amount: Z, Status: W". In Main, call ProcessOrders to filter orders with the status "Pending" and sort by Amount.
Input Format
No input data. Orders are created in the code.
Output Format
Strings with information about filtered and sorted orders. Each string is in the format: "Id: X, Customer: Y, Amount: Z, Status: W".
Examples
Example 1
INPUT
7
insert 10
insert 5
insert 15
search 10
delete 10
search 10
height
OUTPUT
Id: 5, Customer: Eve, Amount: 200.00, Status: Pending
Id: 1, Customer: Alice, Amount: 250.50, Status: Pending
Id: 3, Customer: Charlie, Amount: 300.75, Status: Pending
Example 2
INPUT
5
insert 1
insert 2
insert 3
height
search 3
OUTPUT
Id: 5, Customer: Eve, Amount: 200.00, Status: Pending
Id: 1, Customer: Alice, Amount: 250.50, Status: Pending
Id: 3, Customer: Charlie, Amount: 300.75, Status: Pending
main.cs