Prev
6. Abstract classes and Interfaces
Next
8. Exceptions and Assertions

7. exercise: UML

Main steps

General info

  1. Review presentation UML

      

Set up tools

  1. Install Dia and Calligra Flow graphical editors:

    sudo apt-get install dia calligraflow

    and investigate how to use them for different diagrams.

  2. Download Eclipse IDE for Enterprise Java Developers from bcserver (if available) or from Eclipse website and extract it (if necessary, look for more info here in Latvian).
  3. Install GreenUML plugin

Error solutions after moving to newer Eclipse

  1. If you can't close several opened files in Java editor because tabs doesn't have close button or Close context menu, choose menu:
    File — Close All. When you will opend files again, close button will be shown in the tab.
  2. If context tooltip disappears for editor:
    1. choose menu: Window — Prefereces,
    2. then in tree: Java — Editor — Content Assist — Advanced
    3. Select all proposals regarding to Java for content assist window
    4. Reorder proposals that they start with Java...
  3. If there are other errors, close eclipse, delete .eclipse folder from your home folder, .metadata folder from workspace and .settings folder from the project, and open Eclipse again.

Complete exercise

  1. Investigate jtm.activity07 package
  2. Create class diagram with Green UML:
    1. select menu File — New — Other...,
    2. in wizard tree select Green UML — Green UML Class Diagram and press Next,
    3. in wizard select activity07 for name enter: Animals and press Finish.
  3. Draw UML diagram in jtm.activity07 package (excluding ..Test.. classes)
  4. Export class diagram to Animals.png file in the same package
  5. Implement methods of necessary classes to pass unit tests

Use GreenUML to create a class diagram for Animal, Mammal, Bird, Dog, Hawk classes.
Also generate getters and setters for class properties:

  1. Create class Animal.
    1. Add private field int age;
    2. Add public method void setAge(int age), which allow to set only non-negative number;
    3. Add public method int getAge();
  2. Create class Mammal, which extends Animal.
    1. Add private field boolean isDomestic;
    2. Add public method void setIsDomestic(boolean isDomestic);
    3. Add public method boolean getIsDomestic();
  3. Create class Bird, which extends Animal.
    1. Add private field boolean canFly.
    2. Add public method void setCanFly(boolean canFly);
    3. Add public method boolean getCanFly();
  4. Create class Dog, which extends Mammal.
    1. Add private field String name;
    2. Add public method void setName(String name), which allow to set only name with letters, starting with capital letter;
    3. Add public method String getName();
  5. Create class Hawk, which extends Bird.
    1. Add private field String color;
    2. Add public method void setColor(String color);
    3. Add public method String getColor();
  6. Export created class diagram with all mentioned classes in file Animals.png and save it into ...activity07 package.

Optional tasks

You can create shortcut from Desktop to Eclipse with command:

lxshortcut -o ~/Desktop/Eclipse.desktop

and then set Desktop entry — Command where your Eclipse executable is located.

Additional info

Green UML user guide: https://www.clear.rice.edu/comp310/Eclipse/GreenUML/

UML standard

Other modeling tools

Other UML editors

Other useful editors

Prev
6. Abstract classes and Interfaces
Next
8. Exceptions and Assertions
Tags:
Created by Valdis Vītoliņš on 2017-01-03 10:07
Last modified by Valdis Vītoliņš on 2019-08-08 11:07
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License