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.
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.
Task: Define the actor(s) and the possible Use Cases from the Description above
Task: Write the above use cases in brief, casual or fully dressed versions.
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
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.
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.
Task: A graphical version of a Use Case is called a System Sequence Diagram (SSD) Create one for each Use Case.
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
Task: Based on the Noun List, create a Domain Model with named Associations and Multiplicity
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
Task: Where would you put these methods?
(Hint: Methods should either read or change the data of the object)
Solution
They all goes into Account Class, hence they either read or change the attributes of this class
Task: Create a Class Diagram containing Customer and Account
Task: Add an association to the Class Diagram above.
It should either be of the type: Assosiation, Aggregation or Composition
Task: Based on your Class Diagram, create the Java Classes with Methods and Attributes
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, clbo@kea.dk 2016