#C13426. User Book Management
User Book Management
User Book Management
You are tasked with simulating a simple user book management system. In this system, a user is defined by an ID, username, password, and email. The user can perform two types of operations: purchasing a book and receiving a book recommendation.
A book is represented by its ID, title, author, genre, and price. The operations are given as a sequence of commands. For each command, if the command is purchase, the book is added to the user’s purchased books list. If the command is recommend, the book is added to the recommended books list.
At the end, your program should output two lines: the first containing the IDs of all purchased books (in the order they were added) and the second containing the IDs of all recommended books (in the order they were added). If a list is empty, print None
for that line.
The input and output format are described below. Note that all formulas, if any, are written in LaTeX format. For instance, if a formula was needed it would be presented as \( ax^2+bx+c=0 \), but this problem does not require any particular formula.
inputFormat
The input is read from standard input (stdin) and is structured as follows:
- The first line contains four space-separated items:
id username password email
representing the user data. Note:id
is an integer;username
,password
, andemail
are strings without spaces. - The second line contains an integer
N
denoting the number of operations. - The following
N
lines describe the operations. Each operation line starts with a command which is eitherpurchase
orrecommend
, followed by 5 space-separated elements:book_id title author genre price
.book_id
is an integer,price
is a floating point number, andtitle
,author
, andgenre
are strings without spaces.
outputFormat
The output should be printed to standard output (stdout) with two lines:
- The first line contains the IDs of all purchased books in the order they were added, separated by a space. If there are no purchased books, output
None
. - The second line contains the IDs of all recommended books in the order they were added, separated by a space. If there are no recommended books, output
None
.
1 testuser password123 user@test.com
3
purchase 101 TheGreatGatsby FScottFitzgerald Fiction 10.99
recommend 102 1984 GeorgeOrwell Dystopia 8.50
purchase 103 ToKillAMockingbird HarperLee Fiction 7.99
101 103
102
</p>