Code Monkey home page Code Monkey logo

bank_example_xx's Introduction

Bank Example

An example of Object Oriented Analysis, Design and Programming.
Shows the way from the problem description over Use Case Diagram, Use Cases, System Sequence Diagram, Noun List, Domain Model, Verb List, Class Diagram to the actual Java Code.

This is a step by step Technique for getting from a well written Use Case to the actual Code without "guessing", "thinking" or just creating a class out of the blue. If a Use Case is well written it will decide exactly what classes, attribuetes and methods will apear in the final code.

In this repository you will find Tasks, and when you have solved the tasks the solution for these tasks will be added. You can browse through the tasks and solutions in the Tag menu, in the top left of this page.

Description

A Customer opens a bank account in a bank.
After opening the account the customer can withdraw, deposit and check his balance at any time he wants.
The bank charges a fee of 10kr. for every withdraw a customer makes.
The Customer can not withdraw more money than is on the account including the fee.
The bank also has an interest rate of 8.5%, which is used for calculating a certain amount of interest on the amount deposited by the customer.
The Customer are allowed to have several accounts in this bank.

Use Case Diagram

Task: Define the actor(s) and the possible Use Cases from the Description above

Use Case Diagram

Use Cases

Task: Write the above use cases in brief, casual or fully dressed versions.

UC#1: Withdraw Money

Actor: Customer
Customer requests to withdraw money from his account and specifies the amount.
The bank puts on a fee of 10 kr. when a withdrawal is made, so the customer gets the requested amount, and the fee is subducted on the remaining balance of the account.

Alternative flow:
The requested amount + fee is larger than the balance on the account
Customer gets an error message that there is not enough money on the account.
The balance on the account is displayed

UC#2: Deposit Money

Actor: Customer
The Customer requests to deposit money. The bank calculates the interest based on the interest rate and the amount just deposited, the interest and the amount is summed. The sum is then added to the account balance.

UC#3: Check Balance

Actor: Customer
Customer requests to see the balance of his account.
The account number and name of the customer together with the balance is displayed.

System Sequence Diagram

Task: A graphical version of a Use Case is called a System Sequence Diagram (SSD) Create one for each Use Case.

Noun List

Task: From the Use Cases you should identify all the Nouns. These nouns are the objects and attributes of the object in a Domain Model.

Customer, Money, 
Account, Amount, 
Bank, Fee, Balance, 
Error message, 
interest, interest rate, Account Number, 
Customer Name     

Domain Model

Task: Based on the Noun List, create a Domain Model with named Associations and Multiplicity

Verb List

Task: Create a Verb List
The vers, like the nound, are found in the Use Cases. They are the methods in the Classes
Verbs = Actions = Methods

Withdraw
Display error message
Deposit
Calculate interest
Add to balance
Check Balance

Class Methods

Task: Where would you put these methods?
(Hint: Methods should either read or change the data of the object)

withdraw()

deposit()

checkBalance()

Solution

They all goes into Account Class, hence they either read or change the attributes of this class

Class Diagram

Task: Create a Class Diagram containing Customer and Account

Class Diagram

Class Relations

Task: Add an association to the Class Diagram above.
It should either be of the type: Assosiation, Aggregation or Composition

Composition

Code

Task: Based on your Class Diagram, create the Java Classes with Methods and Attributes

Finnish your program

This concludes the Object Oriented Analasys, Design and Programming circle.
As you will have noticed a lot of code is still missing for you to have a fully working bank example.

Task: Finish the program, and remember to update the affected diagram and use cases if somthing changes.

© Kea, [email protected] 2016

bank_example_xx's People

Contributors

clbokea avatar

Watchers

 avatar  avatar

Forkers

clbokea

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.