You are on page 1of 4

CS284 Software Modeling and Analysis

Exercise 1:
Given the following class diagram, specify the type of relationships between classes and
provide appropriate multiplicity for each relation where possible.

Page 1 of 3
1) Composition
…………………………….Relation
2) Dependency relation
…………………………….
3) Association relation (1;1)
…………………………….
4) Aggregation Relation (1:N)
…………………………….
Inheritance relation
5) …………………………….

Exercise 2:

Take the description of your average PC hardware below and draw a class diagram that
captures the different classes of hardware components and the relationships between those
classes.
PC hardware list:
• Base Station (Tower);
• Keyboard;
• Combined CD and DVD Recorder;
• Motherboard;
• Screen;
• Mouse.
The relationships between these parts are as follows:
• The Base Station contains the Motherboard;
• The Base Station also contains a combined CD and DVD Recorder (Superdrive);
• The Base station is connected to a Keyboard, a Screen and to a Mouse.

Exercise 3:

Define a class diagram for a university. In a university there are different classrooms, offices
and departments. A department has a name and it contains many offices. A person working
at the university has a unique ID and can be a professor or an employee.
• A professor can be a full, associate or assistant professor and he/she is enrolled in
one department.
• Offices and classrooms have a number ID, and a classroom has a number of seats.
• Every Employee works in an office.
Page 2 of 3
Exercise 4:
Design a class diagram for a restaurant app. The owner of a small restaurant wants a new
information system to store data for all meals consumed there and also to keep a record of
ingredients kept in stock. After some research he reached the following requirements list:

• Each ingredient has a name, a measuring unit (e.g. olive oil is measured in
liters, while eggs are unit based) and a quantity in stock. There are no two
ingredients with the same name.
• Each dish is composed of several ingredients in a certain quantity. An
ingredient can, of course, be used in different dishes.
• A dish has a unique name and a numeric identifier.
• There are several tables at the restaurant. Each one of them has a unique
numeric identifier and a maximum amount of people that can be seated there.
• In each meal, several dishes are consumed at a certain table. The same dish can
be eaten more than once in the same meal.
• A meal takes place in a certain date and has a start and end time. Each meal has
a responsible waiter.
• A waiter has a unique numerical identifier, a name, an address and a phone
number.
• In some cases, it is important to store information about the client that
consumed the meal. A client has a tax identification number, a name and an
address.
The relationships in the class diagram are as follows:
1. Composition relationship between `Dish` and `Ingredient`: A dish is composed of
several ingredients. This is represented by a composition relationship, indicated by
the filled diamond shape on the `Dish` side.
2. Composition relationship between `Meal` and `Dish`: A meal consists of several
dishes. This is also represented by a composition relationship, indicated by the filled
diamond shape on the `Meal` side.
3. Association relationship between `Meal` and `Table`: A meal is associated with a
table, indicating that the meal takes place at a certain table. This is represented by a
simple line between `Meal` and `Table`.
4. Association relationship between `Meal` and `Waiter`: A meal has a responsible
waiter, indicating that the waiter is associated with the meal. This is represented by a
simple line between `Meal` and `Waiter`.
5. Association relationship between `Waiter` and `Table`: A waiter is associated with
one or more tables, indicating that the waiter serves customers at those tables. This
is represented by a simple line between `Waiter` and `Table`.
6. Association relationship between `Meal` and `Client`: In some cases, aPage meal
3 of may
3
have associated client information. This is represented by a simple line between
`Meal` and `Client`.

You might also like