1 / 14

Introduction to Java Class Diagrams

Introduction to Java Class Diagrams. Classes. class Account { … }. Account. Attributes. class Account { float balance = 0; float limit; }. Account. balance: float = 0 limit: float. [visibility] attributeName [multiplicity] [: type [ = initialValue ] ]. Visibility.

livi
Download Presentation

Introduction to Java Class Diagrams

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Java Class Diagrams

  2. Classes class Account { … } Account

  3. Attributes class Account { float balance = 0; float limit; } Account balance: float = 0 limit: float [visibility] attributeName [multiplicity] [: type [ = initialValue ] ]

  4. Visibility class Account { private float balance = 0; private float limit; } Account - balance: float = 0 - limit: float • + public • private • # protected • ~ package

  5. Operations (methods) class Account { private float balance = 0; private float limit; public void deposit(float amount) public void withdraw(float amount) } Account - balance: float = 0 - limit: float + deposit( amount: float ) + withdraw( amount: float ) [visibility] methodName( [parameter: type]* ) [ : returnType]

  6. Class scope class Person { private static int numPeople; private String name; public String getName() public static int getNumPeople() } Person - numPeople: int - name: String + getName() : String + getNumPeople() : int

  7. CompositionA comprises local objects that die when A dies class Basket { Item item = new Item(); } Basket Item

  8. Aggregationcomprised of sharable objects class Computer { Device dev; Computer(Device dev) { this.dev = dev; } } Computer Device

  9. Multiplicities class Basket { Item item = new Item(); } 1 Basket Item

  10. Multiplicities class Basket { Item[] item = new Item[5]; } 5 Basket Item

  11. Multiplicities class Basket { // may or may not exist Item item; } 0..1 Basket Item i..j means i <= # objects <= j

  12. Multiplicities class Basket { List<Item> itemList = newArrayList<Item>(); } 0..* Basket Item * means no a priori upper limit

  13. Generalization (is a) Person class Person { … } class Employee extends Person { … } Employee

  14. Realization interface Person { … } class Employee implements Person { … } Person Employee Person Employee

More Related