BadBank simulates the internal settlement system of a (bad) bank. The system periodically processes input files and generates reports.
Syntax:
$ dotnet run --project BadBank.Demo INPUT OUTPUT FREQUENCY
Example (Bash):
$ mkdir -p BadBank/{input,output}
$ dotnet run --project BadBank.Demo BadBank/input BadBank/output 30
Arguments:
INPUT
is a folder path that will be watched for new filesOUTPUT
is a folder path to which reports will be writtenFREQUENCY
is the processing frequency in seconds (integer)
The input files are written in the BadBank Transaction Language (see below).
Example file (input.bbtl
):
open Alice
deposit Alice 100
open Bob
send 25 from Alice to Bob
withdraw 15 from Bob
withdraw 20 from Alice
If the file alice-bob.bbtl
is put into the INPUT
folder, its processing will start after FREQUENCY
seconds the latest. If multiple files are put into the INPUT
folder, they will be processed in alphabetical order (case-sensitive).
Input files will be deleted after processing! So better create a backup for them while testing.
The result will be published as alice-bob.bbrf
(BadBank Reporting Format) in the OUTPUT
folder:
Alice 55.00
Bob 10.00
The following commands are supported:
open ACCOUNT
- semantics: open the account with name
ACCOUNT
- pre-condition: no account of name
ACCOUNT
exists yet - post-condition: an account of name
ACCOUNT
with balance 0.0 exists
- semantics: open the account with name
close ACCOUNT
- semantics: close the account with the name
ACCOUNT
- pre-condition: an account of name
ACCOUNT
exists - post-condition: the account of name
ACCOUNT
no longer exists
- semantics: close the account with the name
send AMOUNT from ACCOUNT_A to ACCOUNT_B
- semantics: send the amount
AMOUNT
fromACCOUNT_A
toACCOUNT_B
- pre-condition: both
ACCOUNT_A
andACCOUNT_B
exist;AMOUNT
must be positive (> 0.0
) - post-condition: balance of
ACCOUNT_A
decreased, balance ofACCOUNT_B
increased byAMOUNT
- Note: no balance check is performed (balance can become negative)
- semantics: send the amount
deposit AMOUNT to ACCOUNT
- semantics: deposit the amount
AMOUNT
forACCOUNT
- pre-condition: an account of name
ACCOUNT
exists - post-condition: balance of
ACCOUNT
increased byAMOUNT
- semantics: deposit the amount
withdraw AMOUNT from ACCOUNT
- semantics: withdraw the amount
AMOUNT
fromACCOUNT
- pre-condition: an account of name
ACCOUNT
exists - post-condition: balance of
ACCOUNT
decreased byAMOUNT
; balance ofACCOUNT
must be>= AMOUNT
- semantics: withdraw the amount
See examples in data/input-examples
.
ACCOUNT AMOUNT
- the account
ACCOUNT
has the givenAMOUNT
(formatted as a floating-point number with two fraction digits, e.g.165.29
)
- the account
See examples in data/output-examples
: