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

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
Get step-by-step solutions from verified subject matter experts
