Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions