Class Diagrams in Analysis

Exercises


Form teams of 4-6 students for the following exercises

Sample Use Case "Buy ticket"

A customer arrives at a ticket counter and wants to buy a ticket for a particular journey. The employee of the airline asks the customer for his wishes concerning The employee enters these wishes into the flight information system which (hopefully) returns data about one or more possible flights matching the query. Each flight ist described by

The customer chooses one of the possible connections found by the system and reserves this flight by getting a ticket for it. The ticket contains some further information such as the date of issue and whether the ticket is paid already or has to be paid at check-in time.

After the customer has received one or more tickets, he has to pay for them. Our sample airline supports two different methods of payment - pay by credit card or by cheque card. If you pay by credit card, the airline registers the number of the credit card and its expiration date. For payment by cheque card the bank code and the number of your bank account are read from the card for an electronic debit note. Independent of the payment method the customer chooses, the airline always records the amount of money being paid, the date of the payment and the signature of the customer.
 

Exercises

1.) Derive a conceptual class diagram from the use case description given above. Use the analysis process presented in the lecture (Slide 3.2.14 ff., find nouns, remove synonyms, turn nouns into classes, ...).
Your results will be discussed during the next lab course.

2.) Until now we only considered Non-Stop Flights. But in reality, there are also many composed flights, i.e. flights where you have to change the plane. If there is no non-stop flight available, the system returns al list of the different flights, the customer has to take in sequence in order to reach his destination. Model this fact in your diagram. There are two alternatives to do this:

a) Use a recursive association to model that a flight may be composed by many other flights. Think carefully about the multiplicities and use role names for both ends of the association, in order to avoid ambiguities.

b) The Design Pattern Composition may be used for this purpose. In the model fragment handed out to you you see part of the design pattern applied to the flight example. Try to understand this model and complete it, so that it models the desired relationship. Since a flight is part of a composite flight, you can use a special type of association here: Aggregation. Discuss, why it does not make sense to use Composition, which is a special form of Aggregation

3.) Now we change to a more implementation-oriented view. We want to inspect the operations and attributes of flights in more detail. For a direct flight the arrival and departure time are stored, but for composite flight departure time is the departure time of the first flight whereas arrival time is the arrival time of the last flight in the sequence, i.e., they are computed not stored. Add the attributes arrival and departure to the classes according to this fact.To hide the difference between direct and composite flights from the user make the attributes departure and arrival private and introduce operations getDeparture and getArrival. Add these operations, so that they exist in both classes Composite Flight and Direct Flight. Make these operations public.


Software Systems Institute

Home of the Java Course Claudia Niederée, Michael Skusa, dec 1999