You are on page 1of 12

1

DCS 235 Software Engineering


Laboratory Assignment 3
An introduction to ArgoUML
Version 1, October 2012
This exercise first introduces you to the software tool for creating UML diagrams (part 1), and then
there are few diagrams you have to create completely on your own (part 2) and have them marked
by a TA.
To obtain 1 mark for this lab you need to demonstrate you have accomplished the Part 1 (class
diagram, sequence diagram, state chart and use case diagram). To obtain 2 marks, both parts have
to be completed.
Part 1
ArgoUML is a basic (free) tool for creating the UML diagrams needed to document the design of
software engineering projects.
You can download ArgoUML from here:
http://argouml.tigris.org/
The tool's help manual is almost empty of content so you will not be able to learn anything from it.
However, the website has a number of introductory tutorial 'tours':
http://argouml.tigris.org/tours/index.html
There are no tutorials or help information about building sequence diagrams (which are definitely
needed on the course) and the above tutorials miss out many key features that you will not find out
about by reading any documentation (because no such documentation exists). So you should
complete all of the following steps to find out how to make the tool more useful.


2

First create a new project that is intended to capture the example described here:
https://intranet.dcs.qmul.ac.uk/courses/coursenotes/DCS235/UML/integrated%20UML%20example
.html .
The first thing to do is make the entire notation consistent with Java. To do this Select
File-->Properties.
In "Notations" select "Java" for "Notation Language".
Now create the class diagram in the same way as in the above tutorial. There are a few 'new' things
you need to know to recreate this class diagram:

Note that the Booking class has an explicit constructor method defined (and that it has two
parameters, something we will deal with later). To add a constructor method select Add-->New
Operation as usual, but in the Properties window select the tab Stereotype. You will see that there
are two available stereotypes:

Add the first of these (create) and the operation will automatically be renamed as Booking() to
reflect the fact it is a constructor.



3

As mentioned, some of the methods (like the constructor for Booking) have one or more
parameters. By default the only "parameter" is the return value, which by default is void. To add
parameters click on the icon:

This should give you a list of all the available 'types' that you can choose from (by default this will
include Integer and String plus any classes that you have defined in the project). You simply select
the type and rename the parameter accordingly. So, once you have added the two parameters for
the Booking constructor you should see the following when you click on the parameter icon for the
Booking constructor:

Note that it is always the case that the first parameter is the return type.

Now note that the EventsList class here has an attribute whose type is a Java class that is not
offered by default (namely ArrayList). The way to get additional classes like this listed as being
available is simply to add a class called "ArrayList" to the project (as opposed to adding it to the
diagram). Any classes in the project will automatically show up as being available as a possible type.
It is also important to note that any classes that you add to the project (as opposed to a class
diagram) can be dragged onto a class diagram at any time. This is useful if you have more than one
class diagram that needs to use the same class. It also turns out to be useful for constructing
sequence diagrams (see below).



4

Now you are going to create the generic "Book Event" sequence diagram. To do this simply right
click on the project name and select: Create Diagram--> New Sequence Diagram:

This creates a sequence diagram, which by default is called "Sequence Diagram", in an object called
"unattachedCollaboration":



By selecting the Sequence Diagram you will see the main properties window in the bottom of the
right-hand panel. You can change the name to "Book event sequence diagram". Similarly, you can
also change the name of the "unattachedCollaboration".

The sequence diagram consists of 'timelines' of objects from Classes (these are called 'classifier roles'
in Argo UML) together with interactions between them.
There are two ways to add these objects - but beware: this is where you will find ArgoUML is
extremely flakey. The nice, quick, and obvious way to add an object like the object called 'aMember'
of class 'Member' is to simply locate the Member class in the left-hand project panel and drag it inot
the sequence diagram window. If you are lucky (and I think I know how to 'get lucky') an object of
class Member will be created and you simply rename it as "aMember". If you are unlucky nothing
will happen and you will have to revert to the other (manual) way of adding objects to the sequence
diagram. The way to get lucky is to always add your classes to the project before you add them to a
class diagram. So, if you know you need a class called "Member" in your main class diagram, then
instead of choosing the add class tool within the class diagram it is better to select add class in the
project window and name it as "Member" before you add it to a diagram. Once it is in the project
window you can drag it into the class diagram and also into a sequence diagram.
5

However, it turns out that even this does not always work for sequence diagrams. It seems to be the
case that once you have dragged a class into a sequence diagram you can never drag another
instance into that sequence diagram or any other.
This means that you will inevitably need to know how to manually create instances of your pre-
defined classes in sequence diagrams, and here is how:
Select the icon for "New classifier role" and click on the canvas.
This creates an empty object timeline.
Rename the object "aMember:Member" (or in general, <objectname>: <classname>). You
must follow this syntax or it will not work.
So, now you know how to create timeline objects of a specific class create the five objects shown
here:

To add the actions between the objects select the 'send action' icon:

Then simply drag it from the source to the target. This will create an unnamed action.
In an ideal world if you right-click on the action you should see the list of available methods
associated with the target class. Having read some newsgroups on ArgoUML this happens
sometimes, but I have yet to work out how to do set it up to do this. Hence you will need to name
the action manually.

6

Note that some actions, namely the last two are constructors and for these the timeline of the
object starts only when the action is initiated. To create such action simply select the 'create action'
icon:

When you drag it between the source and target the target timeline will be shortened accordingly.

7

Some other things to note about using ArgoUML:
You can save the currently open diagram as an image file by selecting "File--> Save
Graphics". However, it is easier (and you seem to get much nicer results) by simply right
clicking on the diagram name in the project window and selecting "Copy diagram to
clipboard as image". Then you can simply paste into your favourite image editing program.
Use case diagrams do not have a 'system boundary' tool within which to group use cases. To
create the system boundary in the example here you have to use the shape and text tool.
Associations in use case diagrams seem to force you to add multiplicities (whereas in the
course we choose not to show multiplicities in use case diagrams).
In statecharts, to create concurrent regions of a complex state (such as the state "GUI
visible" here, where the dotted line separates the concurrent regions) you have to right click
on the state and then you will see the option "New concurrent region".


8

Now try to recreate the following diagrams:
Use case diagram



9

State chart


10

Part 2
Task 1
A bank offers an online currency exchange service to customers so that they can order foreign
currency and have it dispatched (physically) to their local branch for collection. In any order the
customer can buy more than one type of currency. So an order consists of one or more currency
transactions. Every currency transaction has a currency name (type), an exchange rate (which is the
amount of the currency that customers will get for each pound) and the amount (in pounds) the
customer wishes to buy. The bank makes a distinction between common currencies (which includes
dollars and euros) and special currencies (which includes yen and shekels). Special currencies are
not always held by the bank and so an availability check has to be made for these. Also, special
currencies incur a commission (which is not payable on common currencies). Customers who make
regular orders qualify for a discount (depending on the amount and size of orders). Customers must
deposit sufficient balance to pay the full costs of an order. Providing that the currencies ordered are
available, the system calculates the total cost of the order and debits the customers balance
accordingly, taking account of the customers current discount status. A summary of the order is
displayed and the currency is dispatched to the local branch. Any remaining balance can either be left
in the account for future orders or withdrawn.
The five basic classes classes needed for a class diagram for this system are:
CommonCurrency, Customer, CurrencyTransaction, Order, SpecialCurrency
A subset of the attributes, methods, and constructors required for this class diagram are:
Boolean getIsAvailable()
Boolean isAvailable
Customer aCustomer
double amount
double balance
double calculateTotalCost()
double commissionRate
double discount
double exchangeRate
double getBalance( )
double getDiscount()
double setDiscount()
List currencyTransactions
Order( )
String currencyName
String customerName
void addToBalance( double amount )
void checkOut( )
void deductFromBalance( double amount )
void dispatch( )
void login( )
void logout( )
void printSummary( )
void addCurrencyTransaction()
void calculateCommission (double pounds)
void calculateTotalCost()
void convert(double pounds)
void removeCurrencyTransaction()
void setAmount(double pounds)


Draw the class diagram including all of the above in the appropriate classes. You should also make
clear whether the attributes and methods are private or public, and you should also add any relevant
associations between classes.

11

Task 2
Consider the following use case scenario:
The customer Jane logs in and checks her current balance. She adds 350 to the balance so that she
can make an order for dollars and yen. She orders 200 of dollars (the system does the conversion
and adds it to the order) and then orders 100 of yen (the system checks availability, does the
conversion, calculates the commission and adds it to the order). The system performs all the
necessary checks and calculations to determine the overall cost of the order and resets Janes balance
and discount status accordingly. The system prints a summary of the order and dispatches the dollars
and yens to Janes local branch. Jane checks her remaining balance and logs out.
Complete the sequence diagram (shown in Figure 1) for this use case scenario. With the exception of
the constructor shown in Figure 1 you can ignore the need for any other constructors (i.e. you can
assume these objects exist). You should not add any more objects than those shown, and you should
only use methods from the above list. There should be about 20 additional message passes in total.


Figure 1

Jane
dollars: CurrencyTransaction
yen: CurrencyTransaction Jane: Customer Jane: Customer
anOrder: Order
login()
getBalance()
Jane
dollars: CurrencyTransaction
yen: CurrencyTransaction Jane: Customer Jane: Customer
anOrder: Order
login()
getBalance()
12

Task 3
Draw a statechart that captures the key information about the following simple digital watch:
After unpackaging you have to insert a battery to get the watch started. Before the time is displayed
you have to set the time, which is done first by pressing the button S to start the time-setting mode. To
add one hour you must press the button T (so, for example you must press the button 5 times to set the
hour as 5 if the default is 0). Once the hour is correct you must press the button S which puts you into
the minute setting mode (where each press of the button T moves you forward one minute). Pressing
the button S now displays the time set. At any time pressing the button S will take you into time setting
mode. The watch has a light button L which , when first pressed will light the display. Pressing L
again switches the light off. Removing the battery at any time causes the watch to stop working.

You might also like