Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

COMP246 Test 2 Fall 2020 ---- 20 mins

Written Question. (10 Marks)

Copy and paste ONE component design class diagram done in your
Term Project Part B. Make sure that the component has a name.

The component design must have the following:

1. THREE or more collaborating classes.


2. The design MUST have followed at least one design pattern. Identify
the design pattern(s) that you have used in the component design.
Briefly explain at least one pattern as you have applied it in the
context of the component design.
3. In not more than 3 sentences, describe the functionality of the design
component that you selected. Include words such as functional
independence, encapsulation, cohesion and coupling in your
description.
4. Describe THREE methods contained in the classes in 3 separate
sentences. You may choose methods from any of the classes that
make up the selected component.
5. Describe the multiplicity/cardinality between any 2 classes.

1
Figure: User Flight Search and Tracking Subsystem

1. Three Collaborating Classes:

 The User, Flight, and NotificationSetting classes collaborate within the system.
User maintains user profiles, Flight holds flight-related data, and
NotificationSetting stores user preferences for notifications.

2. Design Pattern:

 Observer Pattern: This pattern is suggested by the relationship between Flight


and Notification. The Flight class would be the subject, and when its status
changes, it notifies the Notification class, which acts as an observer.

 Explanation: When a Flight object changes state (e.g., delay or cancellation), the
Notification objects associated with it are automatically informed and updated,
promoting a decoupled system where Flight doesn't need direct knowledge of its
observers, thus maintaining functional independence and loose coupling.

2
3. Functionality Description:

 The system's design ensures that flight information is managed with high
cohesion within the Flight class, user data is securely encapsulated within the
User class, and notification preferences are independently handled in the
NotificationSetting class, promoting functional independence and reducing
coupling.

4. Three Methods Description:

 User.login(): Authenticates a user's credentials and grants access to their profile


and flight information.

 Flight.checkAvailability(): Checks seat availability for a particular flight and


returns the current status.

 NotificationSetting.updatePreferences(): Allows a user to change their


notification preferences for receiving updates about flights.

5. Multiplicity/Cardinality Between Two Classes:

 Between User and NotificationSetting: The cardinality is 1 to 1 (1..1), meaning


each user has one associated set of notification preferences.

 Between Flight and User: The cardinality is 1 to many (1..*), indicating that a
user can be associated with multiple flights for tracking or notifications.

You might also like