Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{greenpepper-info}{panel:title=Bank Example| borderStyle=solid| borderColor=#ccc| titleBGColor=#8CC06D| bgColor=#FFFFCE}
The main purpose of this example is to show you :
* [How to handle business flows using the 'Do With' Interpreter|http://www.greenpeppersoftware.com/confluence/display/GPO/Writing+an+executable+specification+with+the+Do+With]
* [How to convert a String to a Money type using 'Type Conversion'|http://www.greenpeppersoftware.com/confluence/display/GREENPEPPER/Type+conversion+%28JAVA%29]
{panel}{greenpepper-info}

{greenpepper-import:

|| import ||
|com.greenpepper.confluence.demo.bank|
|GreenPepper.Confluence.Demo.Bank}|
 
h3. Account Management Example
|| do with || Bank ||
| open checking account | 12345-67890 | under the name of | Bart | | Simpson |
| check | that balance of account | 12345-67890 | is | $0.00 |
| deposit | $100.00 | in account | 12345-67890 |
| check | that balance of account | 12345-67890 | is | $100.00 |
| withdraw | $50.00 | from account | 12345-67890 |
| check | that balance of account | 12345-67890 | is | $50.00 |
| reject| withdraw | $75.00 | from account | 12345-67890 |
| check | that balance of account | 12345-67890 | is | $50.00 |
| accept | withdraw | $25.00 |from account | 12345-67890 |
| display | the balance of account | 12345-67890 | 

| end |

h3. Opening different account type

|| do with || Bank ||
| open checking account | 12345-67890 | under the name of | Bart | | Simpson |
| open savings account | 54321-09876 | under the name of | Lisa | | Simpson |

|| set of || opened accounts ||
|| number || type || owner name ||
| 12345-67890 | checking | Bart Simpson|
| 54321-09876 | savings | Lisa Simpson |

| end |

h3. Freezing an Account

|| do with || Bank ||
| create | savings | account |11111-22222 |for | Homer |  | Simpson | with balance of| 1546.23|
| accept|withdraw | $100.00 |from account| 11111-22222 | using | ATM|
| freeze account| 11111-22222 |
| reject|withdraw | $100.25 |from account| 11111-22222 | using | ATM|
| accept|deposit | $200.00 |in account| 11111-22222 |

| end |

h3. Source Code
{greenpepper-info}
[^AccountType.java]
[^Bank.java]
[^BankAccount.java]
[^BankFixture.java]
[^CheckingAccount.java]
[^Money.java]
[^NoSuchAccountException.java]
[^Owner.java]
[^SavingsAccount.java]
[^WithdrawType.java]
{greenpepper-info}