Question: [Java] [Bridge Pattern] Consider a shape display system which can display shapes in several output formats. All shape classes in the system have a deferred

[Java] [Bridge Pattern]

Consider a shape display system which can display shapes in several output formats.

All shape classes in the system have a deferred class SHAPE as their ancestor. For example, the following figure shows part of the shape hierarchy:

[Java] [Bridge Pattern] Consider a shape display system which can display shapes

Classes SCREEN and PRINTER are used to display shapes on a screen or printer respectively:

class SCREEN

feature

draw_line (x1, y1, x2, y2: INTEGER) is ?? Display a line from (x1, y1) to (x2, y2).

draw_pixel (x, y: INTEGER) is ?? Display a pixel at (x, y).

draw_circle (x, y, r: INTEGER) is ?? Display a circle at (x,y) with radius r.

end

class PRINTER feature

print_line (x1, y1, x2, y2: INTEGER) is ?? Print a line from (x1, y1) to (x2, y2).

print_pixel (x, y: INTEGER) is ?? Print a pixel at (x, y).

print_circle (x, y, r: INTEGER) is ?? Print a circle at (x,y) with radius r.

end

Design a system which allows new shapes and new output formats to be added easily (Bridge Pattern?). You are required to add a new shape POLYGON and a new output format XML_WRITER.

SHAPE CIRCLE RECTANGLE SHAPE CIRCLE RECTANGLE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!