#C12709. Implement an E-Commerce User Order System
Implement an E-Commerce User Order System
Implement an E-Commerce User Order System
You are required to implement a User class simulating a part of an e-commerce platform. The User
class should have a constructor that initializes the user with an email, password, and name. In addition, each user has an initially empty list of orders. The class must provide a method add_order
that appends an order to the user's list of orders and returns the updated list.
An order is described by an order id, a total price, and a list of product names. You need to process several test cases. For each test case, the program will first receive the user details, followed by a number of orders to add. After processing all orders, output the user details, the number of orders, and then each order’s information as specified.
Note: All input should be read from standard input (stdin) and all output must be printed to standard output (stdout). If any formula is needed in explanation, please use LaTeX format.
inputFormat
The input starts with an integer T (\(1 \leq T \leq 100\)), which is the number of test cases. Each test case has the following format:
- A single line containing three space-separated strings:
email
,password
, andname
. - A line containing an integer N (\(0 \leq N \leq 100\)) indicating the number of orders to add.
- For each of the next N lines, the order details are provided in the following order: an integer
order_id
, a floating point numbertotal_price
, an integerM
indicating the number of products in this order, followed byM
product names (each a string without spaces).
outputFormat
For each test case, output the following:
- A single line with the user's
email
,password
, andname
separated by a single space. - A line with the total number of orders added.
- For each order, a line containing the
order_id
,total_price
, and the list of products concatenated as a comma-separated string (without spaces), all separated by a single space.
Each test case's output should be printed consecutively in the same order as input.
## sample3
test@example.com password TestUser
2
1 100.0 2 product1 product2
2 50.0 1 product3
john@doe.com qwerty JohnDoe
1
5 200.5 3 book pen notebook
alice@wonderland.com rabbit Alice
0
test@example.com password TestUser
2
1 100.0 product1,product2
2 50.0 product3
john@doe.com qwerty JohnDoe
1
5 200.5 book,pen,notebook
alice@wonderland.com rabbit Alice
0
</p>