Home CPSC 240

Lab 3: UML Class Diagrams

 

Objective

To get experience making UML diagrams.


 

UML Tools

There are several tools that can be used to make UML diagrams. Two choices that you can use are:

  1. Dia is an application that can be installed on your computer. It is available for Linux, Windows and Mac computers. When you start Dia, it will be set up to draw general diagrams. On the left is a menu which says "Assorted". If you click on this, you can select "UML" instead. Then the preset shapes will be UML elements:

    There are lots of UML elements to choose, but the only one we need now is the first, the UML class. Add a class to your diagram, then right-click and select "Properties...". You will then be able to edit the class's instance variables, and methods in a dialog window:

    You can change the class name in the "Class" tab. In the "Attributes" tab, you can add instance variables to the class. The "Operations" tab is for adding methods to the class. You can set these up in this window and then they will be inserted into the image.

    Dia saves its files as ".dia" diagrams, but can also export to lots of other formats.

  2. draw.io is a web-based tool for creating diagrams. It can save diagrams to web-storage like Google drive or your own computer. When you create a new diagram with it, it will also be set up for general diagrams. Like Dia, you can choose to use UML tools with it:

    Like Dia, we can add a class element (the third one in the top row). Unlike Dia, there is no dialog window for editing the class details — we do it right in the image.

    Draw.io lets you save the diagram to either your computer, by downloading it, or to web storage options. Like Dia, it saves in a custom format, but also lets you export as a regular image file.

If you want to use another tool, that's OK too!


 

Task

For this lab, you will make a UML class diagram for a class called "Student". It should have the following instance variables:

It should also have one class variable. Remember these are shared amongst all instances of a class:

It should also have the following methods:


 

Submitting

When you are done, please email your UML image file to ifinlay@umw.edu.

If you are using Dia, you can email me either a .dia file, or a .png image. If you are using something else, please send me a .png

Copyright © 2019 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.