Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Java: Implement the bridge pattern by creating a geometric modeling program that defines an abstract base class called Shape that models a generic shape.

Using Java:

Implement the bridge pattern by creating a geometric modeling program that defines an abstract base class called Shape that models a generic shape. Sub-classes of this class are concrete implementations of specific shapes. For example, you would have a Square class, Circle class, and so on. Shapes use formatter classes to render shapes on output devices. The system currently has two of these classes:

image text in transcribed

Draw a UML diagram that documents the current design. Modify this design so that one can add new shapes and new output formats independently 2 of each other. Document your new design. Implement a prototype (Id suggest in Ruby but use your programming language of choice) that demonstrates how you can add a Polygon and XMLForamatter classes to your design. Note that you dont need to do any sort of fancy output in your prototype. Just add print statements that state what each command would do on an actual device. Note that this is an exercise in the application of the Bridge pattern.

class Screen def drawLine(x1,y1,x2,y2) end def drawPixel(x,y, color) end def drawCircle(x, y,radius) end class Printer def drawLine(x1,y1,x2,y2) end def drawPixel(x,y, color) end def drawCircle(x, y,radius) end end class Screen def drawLine(x1,y1,x2,y2) end def drawPixel(x,y, color) end def drawCircle(x, y,radius) end class Printer def drawLine(x1,y1,x2,y2) end def drawPixel(x,y, color) end def drawCircle(x, y,radius) end end

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions