In this lab you will practice using a UML diagram tool to create class and
sequence diagrams.
The tool,
called
Violet, is written by Cay Horstmann, our textbook author.
Here is a link to Horstmann's
Violet information page:
http://horstmann.com/violet/
- Violet comes as an executable Java archive file which you can download
here:
violet.jar
- You must have Java installed on your machine.
- On some operating systems you can launch Violet by double-clicking its
icon. If that doesn't work for you, open a command window, change to the
folder where your violet.jar file is located, and run the command:
java -jar violet.jar
You should see a screen that
looks like:
This section describes basic operations for class diagrams in Violet,
such as creating a
new diagram and manipulating its parts.
This short overview is not a complete description of Violet; it is just
intended to get you started.
Select
File > New > Class Diagram to create a new drawing area
laid out in a grid. Note the diagram tools arrayed to the right of the
drawing area window:
Click to select the "
Class" tool. Any time a tool is
selected, that is the type of diagram component (whether it is a class,
relationship arrow, etc.) that will be created when you click again.
Locate a place in the window where you want to
put a node (class icon), and click there. An empty rectangle will appear.
You can move the node around by dragging it with the mouse. If you
right-click in the rectangle you get a
Properties dialog that will
allow you to enter a class name, attributes, and methods.
Experiment until you get two nodes that look like this:
Since a team is an aggregate of players, select the "
Is an aggregate of" tool,
click anywhere in the
Team class, and drag to anywhere in the
Player class. If the classes occupy the same horizontal strip within
the diagram, you will get an edge (connecting line) like:
Click the
Select tool and drag the
Player class icon down an
inch or two:
All edges have a
bentStyle property that defines the style of
the edge.
The
bentStyle of our edge is currently
HVH
(
horizontal-vertical-horizontal).
You can control the
bentStyle of an edge by right-clicking on it
to get the edge's property editor:
Here the edge's
bentStyle property has been changed to
VH (
vertical-horizontal; the vertical emanates from the origin
class icon, which is
Team):
Violet will attempt to maintain the
bentStyle properties of an
edge as you move associated nodes around:
You can use an edge's property editor to indicate the class
multiplicities for the nodes that it connects:
You can add notes to a diagram by selecting the
Note tool and
clicking anywhere in the diagram.
Then, right-click on the note icon to get the note's property editor.
Finally, select the
Note connector tool to connect the note to
some aspect of the diagram:
Your job is to create a class diagram and sequence diagram as described
in this section.
Create a class diagram that looks exactly like the one below, except
that
<YOUR NAME HERE> is replaced by your name.
Save your diagram as
CS2511_Lab_3. Violet will actually create
the file
CS2511_Lab_3.class.violet. (Do not export the diagram
to an image file.)
Submit your
CS2511_Lab_3.class.violet
and
CS2511_Lab_3.sequence.violet files in a folder zipped with the
name
your-login-LEX3.zip.
Email the zip file to your TA.
Note that the grader
will open your diagram in Violet.
- Class Diagram: 5 points
- Sequence Diagram: 5 points