#K58817. Account Manager Simulation
Account Manager Simulation
Account Manager Simulation
You are given a series of commands to simulate a simple account management system. The system maintains accounts where each account has a unique identifier, a name, an age, and a balance. Your task is to process a sequence of commands and output the result for all balance
queries.
The available commands are:
add id name age balance
: Create a new account with the given id (an integer), name (a string), age (an integer) and balance (an integer).update id balance
: Update the balance of the account with the given id to the new balance.balance id
: Retrieve and output the current balance of the account with the given id.delete id
: Delete the account with the given id from the system.
You may assume that all commands are valid and are executed sequentially. For every balance
command, print the current balance of the account on a new line.
The internal operations can be represented by the following idea in mathematical notation:
$$\text{If } command = \texttt{balance } id, \text{ then output } B(id), \quad \text{where } B(id) \text{ is the current balance of account } id. $$inputFormat
The input is read from standard input (stdin) and is formatted as follows:
- The first line contains an integer
n
, representing the number of commands. - The next
n
lines each contain a command in one of the four formats described above.
outputFormat
For each balance
command in the order they appear, output its result on a new line to standard output (stdout).
7
add 1 Alice 30 1000
add 2 Bob 27 1500
balance 1
update 2 2000
balance 2
delete 1
balance 2
1000
2000
2000
</p>