Giter VIP home page Giter VIP logo

badbank's Introduction

BadBank

BadBank simulates the internal settlement system of a (bad) bank. The system periodically processes input files and generates reports.

Usage

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 files
  • OUTPUT is a folder path to which reports will be written
  • FREQUENCY 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

BadBank Transaction Language (BBTL)

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
  • 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
  • send AMOUNT from ACCOUNT_A to ACCOUNT_B
    • semantics: send the amount AMOUNT from ACCOUNT_A to ACCOUNT_B
    • pre-condition: both ACCOUNT_A and ACCOUNT_B exist; AMOUNT must be positive (> 0.0)
    • post-condition: balance of ACCOUNT_A decreased, balance of ACCOUNT_B increased by AMOUNT
    • Note: no balance check is performed (balance can become negative)
  • deposit AMOUNT to ACCOUNT
    • semantics: deposit the amount AMOUNT for ACCOUNT
    • pre-condition: an account of name ACCOUNT exists
    • post-condition: balance of ACCOUNT increased by AMOUNT
  • withdraw AMOUNT from ACCOUNT
    • semantics: withdraw the amount AMOUNT from ACCOUNT
    • pre-condition: an account of name ACCOUNT exists
    • post-condition: balance of ACCOUNT decreased by AMOUNT; balance of ACCOUNT must be >= AMOUNT

See examples in data/input-examples.

BadBank Reporting Format (BBRF)

  • ACCOUNT AMOUNT
    • the account ACCOUNT has the given AMOUNT (formatted as a floating-point number with two fraction digits, e.g. 165.29)

See examples in data/output-examples:

badbank's People

Contributors

lehrerbucher avatar

Watchers

Patrick Bucher avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.