Atpakaļ
6. Abstract classes and Interfaces
Tālāk
8. Exceptions and Assertions

7. exercise: UML

  1. Review presentation UML

      

  2. Investigate jtm.activity07 package
  3. Install Dia and Calligra Flow graphical editors:

    sudo apt-get install dia calligraflow

    and investigate how to use them for different diagrams.

  4. Download Eclipse Neon for Java EE from bcserver (if available) or from Eclipse website and extract it
  5. Install GreenUML plugin
  6. Draw UML diagram from jtm.activity07 package (excluding ..Test.. classes)
  7. Export class diagram to Animals.png file in the same package
  8. Implement methods of necessary classes to pass unit tests

Create classes and implement methods

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

Additional info

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

UML standard

Other modeling tools

Other UML editors

Atpakaļ
6. Abstract classes and Interfaces
Tālāk
8. Exceptions and Assertions
Tagi:
Izveidojis Valdis Vītoliņš 2017-01-03 10:07
Pēdējais mainījis Valdis Vītoliņš 2017-08-31 18:44
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License