From the course: Python: Design Patterns

Unlock this course with a free trial

Join today to access over 24,600 courses taught by industry experts.

Bridge example

Bridge example

- [Instructor] Let's first define our implementation-specific classes. The first one is DrawingAPIOne, it has a method called draw_circle, and accepts three arguments, x-coordinate, y-coordinate, and radius. It prints a message saying, "API 1 drawing a circle at coordinate x and y with radius." There's another implementation-specific class we need to define, DrawingAPITwo. We'll start with the method by typing def. The name of the method is draw_circle. Its arguments are self, x, y, and radius. The interface is the same, but the implementation will be different. Type print. We'll Copy, Paste. The difference in the implementation lies in the message to be printed. So instead of API 1, we'll say API 2. Now let's define our implementation-independent class Circle. How to draw a circle is implementation-dependent, but some things are implementation-independent when defining a Circle. The very first part of the Circle class definition is initializing its attributes. We have x-coordinate…

Contents