# The `bank` program
The `bank` program takes one command line argument, as follows:
%
That is, it is called with a `
the `init` program. You can assume that it will NOT be called with any
other file than one that was created with your `init` program.
## Behavior of the `bank` program
* If `
Error opening bank initialization file
and return value 64.
* Otherwise, present the bank prompt
BANK:
(note the space at the end) and process bank commands, as described
below.
### Bank commands
The bank should support the following commands:
* `create-user
* Inputs
* `
case characters (`[a-zA-Z]+`). (Valid user names are at most 250
characters.)
* `
* `
be represented with an `int`.
* Behavior
* If the inputs to the command are invalid, then print
Usage: create-user
There should be no side effects in this case.
* Otherwise, if there is already a user with that (case-sensitive)
name, then print
Error: user
Here, `
There should be no side effects in this case.
* Otherwise, it should create a user named `
the bank with an initial balance of `$
also create a file called `
directory. (If you run `./
the file in `.`, not in `
files, the contents can be whatever you want: it’s part of your
design.
* If it is unable to create the file, then it should print
Error creating card file for user
and roll back any changes the bank may have made.
Here, `
* Otherwise, if it successfully creates the file, then it should
print
Created user
Here, `
* In any of the above cases, it should return the user back to
the bank prompt for more commands.
* **Note:** Your protocol cannot modify card files after creating them.
* **Note:** The bank should not have any user accounts pre-established:
these will be created at run-time with a `create-user` command.
* `deposit
* Inputs
* `
case characters (`[a-zA-Z]+`). (Valid user names are at most 250
characters.)
* `
be represented with an `int`.
* Behavior
* If the inputs to the command are invalid, then print
Usage: deposit
There should be no side effects in this case.
* Otherwise, if there is no such user, then print
No such user
There should be no side effect in this case.
* Otherwise, if the `
print
Too rich for this program
There should be no side effect in this case.
* Otherwise, the command will add `$
`
this should print
$
Here, `
* `balance
* Inputs
* `
case characters (`[a-zA-Z]+`). (Valid user names are at most 250
characters.)
* Behavior
* If the inputs to the command are invalid, then print
Usage: balance
* Otherwise, if there is no such user, then print
No such user
* Otherwise, if `
the command with print
$
* No matter the input, this command should have no side effects
(beyond printing).
* Any other commands are invalid (note that withdrawals are not supported
at the bank), and should result in printing
Invalid command
## Example transcript
Here is an example transcript of using the bank: suppose that no users
exist yet.
BANK: balance Alice
No such user
BANK: create-user Alice 1234 100
Created user Alice
BANK: deposit Alice 2
$2 added to Alice’s account
BANK: balance Alice
$102
BANK: