Skip to main content
eick-at moodle
  • Home
  • Calendar
  • More
You are currently using guest access
Log in
eick-at moodle
Home Calendar
Expand all Collapse all
  1. OOP with JAVA
  2. Basics of object-oriented programming with Java
  3. UML: use case diagram and sequence diagram

UML: use case diagram and sequence diagram

Completion requirements
Opened: Sunday, 5 May 2019, 12:00 AM
Due: Sunday, 5 May 2019, 12:00 AM

Use case diagram

This type of diagram can be used to easily show who can do what with the software system, and which use cases are realized by the application:

Use case diagram of an application named ATM Manageruse case diagram



Along with the class and object diagram

class diagram and object diagram of ATM Manager class diagram and object diagram



the following code results:


 1 public class AutomatedTellerMachine {
 2     private double moneySupply;             // encapsulated property: in all methods of class accessible
 3 
 4     AutomatedTellerMachine(float moneySupply) {
 5         this.moneySupply = moneySupply;
 6     }
 7 
 8     public double getMoneySupply() {
 9         return moneySupply;
10     }
11 }
 1 import java.util.ArrayList;
 2 import java.util.Collection;
 3 
 4 public class Bank {
 5     private double totalMoneySupply;
 6     private Collection<AutomatedTellerMachine> automatedTellerMachines = new ArrayList<>();   // Bank has * atm's
 7 
 8     public Bank(Collection<AutomatedTellerMachine> automatedTellerMachines)
 9     {
10         this.automatedTellerMachines = automatedTellerMachines;
11     }
12     public double getTotalMoneySupply()
13     {
14         return totalMoneySupply;
15     }
16 
17     public void sumMoneySupply()
18     {
19         totalMoneySupply = 0;
20         for (AutomatedTellerMachine automatedTellerMachine: automatedTellerMachines)       // sum money supply
21             totalMoneySupply += automatedTellerMachine.getMoneySupply();
22     }
23 }
 1 import java.util.ArrayList;
 2 import java.util.Arrays;
 3 
 4 public class Main {
 5 
 6     public static void main(String[] args) {
 7 
 8         AutomatedTellerMachine atm1 = new AutomatedTellerMachine(12000);
 9         AutomatedTellerMachine atm2 = new AutomatedTellerMachine(8000);
10         AutomatedTellerMachine atm3 = new AutomatedTellerMachine(10000);
11 
12         Bank bank1 = new Bank(new ArrayList<>(Arrays.asList(atm1, atm2, atm3)));// Creation of bank object:
13                                                                                 // a list with references to atm's is copied
14         System.out.println("Money supply of atm1: " + atm1.getMoneySupply());
15 
16         bank1.sumMoneySupply();
17         System.out.println("Total money supply bank1: " + bank1.getTotalMoneySupply());
18         System.out.println(bank1.getTotalMoneySupply());
19     }
20 }

Sequence diagram

This type of UML diagram represents the interactions of the objects among themselves (ie the method calls):

Sequence diagram of ATM ManagerSequence diagram





________________________________________________________________________________________________________________________________________

Task:

Task: Delete the property totalMoneySupply of the class Bank without replacement. The functionality should be preserved by the method sumMoneySupply() returns the total money supply as a return value. For this, the four UML diagrams have to be partially changed.

You are currently using guest access (Log in)
Data retention summary
Get the mobile app
Powered by Moodle