Define the Renderer implementations

Step 1 - Define the Renderer implementations

The Bridge pattern splits a design into two hierarchies: an abstraction and an implementation. Here the implementation is the Renderer - the backend that actually turns a shape into output. We start with just circles.

Implement the two Renderer subclasses:

  • VectorRenderer.render_circle(radius) returns 'vector circle r=5' for radius 5.
  • RasterRenderer.render_circle(radius) returns 'raster pixels for circle r=5'.

Build each result by concatenating the fixed prefix with str(radius) so any radius works. The Renderer base class just declares the method.

Hints
Starter code
class Renderer:
    def render_circle(self, radius):
        raise NotImplementedError

class VectorRenderer(Renderer):
    def render_circle(self, radius):
        """Return a vector description of a circle of the given radius."""
        # TODO: return a string like 'vector circle r=5'
        pass

class RasterRenderer(Renderer):
    def render_circle(self, radius):
        """Return a raster description of a circle of the given radius."""
        # TODO: return a string like 'raster pixels for circle r=5'
        pass
Write it on a laptop

The editor and the test runner need a wide screen. Open this page on a desktop browser and your progress will be waiting.