Dijagram klasa UML to JAVA Prof dr Angelina

  • Slides: 13
Download presentation
Dijagram klasa: UML to JAVA Prof. dr Angelina Njeguš Associate Professor

Dijagram klasa: UML to JAVA Prof. dr Angelina Njeguš Associate Professor

Korak 1: Kreiraj UML projekat • File > New > Project • Check Show

Korak 1: Kreiraj UML projekat • File > New > Project • Check Show all wizards • Expand Modelling folder, select UML Project, and click Next • Choose a name for your project and click Next. – Project name: Bank

Korak 2: Kreiraj paket • Select General > Blank Package • Choose a name

Korak 2: Kreiraj paket • Select General > Blank Package • Choose a name for your package and click Finish. – File name: Bank. Account • What is package? – A package is a general purpose mechanism for organising elements into groups. – Packages may be nested within other packages.

Korak 3: Nacrtaj dijagram klasa • In the Project Explorer View, right click on

Korak 3: Nacrtaj dijagram klasa • In the Project Explorer View, right click on the package Bank. Account and select Add Diagram > Class diagram • In the Palette view, click on Class, and name it Account • Right click on Account, and select Add UML > Attribute • Name the attribute: -balance : double, and click Enter.

Dodavanje operacija • Right click on class Account, and select Operation • Name the

Dodavanje operacija • Right click on class Account, and select Operation • Name the operation: deposit(amount: double): double, and click Enter • Add another operation: withdrawal(amount: double): double

Dodavanje novih klasa • Add new class: Checking. Account – Attribute: insufficient. Funds. Fee:

Dodavanje novih klasa • Add new class: Checking. Account – Attribute: insufficient. Funds. Fee: double – Operation: withdrawal(amount: double) • Add new class Savings. Account – Attribute: annual. Interest. Rate: integer – Operations: deposit. Monthly. Interest(), and withdrawal(amount: double)

Dodavanje relacija • In the Pallete View, under Class, select Generalization, and draw on

Dodavanje relacija • In the Pallete View, under Class, select Generalization, and draw on the diagram

Korak 4: UML-to-Java transformacija • To create a new UML-to-Java transformation configuration, select Modeling

Korak 4: UML-to-Java transformacija • To create a new UML-to-Java transformation configuration, select Modeling >Transform > New Configuration in the Main menu.

Configure the transformation • In the Name field of the opened New Transformation Configuration

Configure the transformation • In the Name field of the opened New Transformation Configuration wizard, enter the name of the transformation configuration: – Name: My. UMLto. Java. Transform • Click the ellipses (. . . ) button to browse to the UML project Bank • In the list of deployed transformations, open the Java Transformations folder and select the UML-to-Java transformation. • Select the Conceptual protocol type, and click Next. Note: Choose Conceptual protocol if the intention is to use the source model as a primary engineering artifact in future iterative development. Any changes made to the source model will be propagated to the target project when someone runs the transformation.

Specify the source and target elements for the transformation • Select the model Bank.

Specify the source and target elements for the transformation • Select the model Bank. Account from the created UML project as a source • Select Create a Target Container

Create a new Java project • Create a new Java project named my. Bank.

Create a new Java project • Create a new Java project named my. Bank. Code, and click Finish • Select it as a target in the Transformation Configuration wizard, and click Finish

Run the transformation configuration • The Java project and transformation configuration files created are

Run the transformation configuration • The Java project and transformation configuration files created are visible in the Project Explorer view • The Transformation configuration is opened in the Editor view • Click Run to run the configuration

Generated transformation output • The Java code will be generated in the target project

Generated transformation output • The Java code will be generated in the target project