Describe where the observer pattern is used in the analysis model (participating classes, roles). Answer the same question for the source code (object model).

Observer pattern – Implementation
We will show the Observer pattern implementation
Exercise – Programming Assignment: Adapter pattern
1) Adapter pattern – Modeling
A new instrument (AnalogSpeedometer) from a legacy system has to be integrated
into Asteroids (see Figure 1). The existing class AnalogSpeedometer must not be
changed. Therefore an Adapter pattern should be used. Integrate the
AnalogSpeedometer into the existing model.
Figure 1: Asteroids classes, AnalogSpeedometer
Task 1) Mapping the analysis objects to code
The analysis objects in Figure 1 are implemented in the source code. For every class
in the analysis model specify its implementing class and its package in the source
code (and therefore in the object model). Hint: There is not necessarily a one to one
mapping.
Task 2) Identification of the observer pattern
Describe where the observer pattern is used in the analysis model (participating
classes, roles). Answer the same question for the source code (object model).
Task 3) Extension of the model
Extend the analysis model by a new class Compass that shows the direction of the
space shuttle.
Task 4) Observer pattern – Implementation (programming assignment)
Implement the Compass according to your analysis.
Task 5) Bonus: Adapter pattern
Assume there the following new requirement has been formulated for the Asteroids
game:



IMPORTANT – Submission Requirements for programming assignment:

Warning: Due to the large number of students, it is very important to exactly fulfill the

submission requirements. Otherwise your submission cannot be processed.

• Only code compiling without any errors will be accepted. Do not submit non-

compiling code!

• Use Java 1.5 and the supplied ANT script to compile • To submit your

solution, execute the ANT target “zip”. When prompted to do so

enter your exercise group and the last name of all of your team members. •

Please double check the generated “zip” file in the asteroids directory:

o It should be named following the schema --

--Exercise05.zip:

o Unzip once and check the contents: source code folder (“src”) and jar archive

• In your email... o ...choose the name of the zip archive as subject o ...note the

complete name and “Matrikelnummer” of all team members

Computer Science & Information Technology

You might also like to view...

Which of the following statements restores the default fill character?

a. cout.defaultFill(); b. cout.fill(); c. cout.fill( 0 ); d. cout.fill( ' ' );

Computer Science & Information Technology

Once you start recording a macro, any task you perform in Excel will be part of the macro.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology