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:
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 RECTANGLEStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started