File tree Expand file tree Collapse file tree 1 file changed +15
-11
lines changed
Expand file tree Collapse file tree 1 file changed +15
-11
lines changed Original file line number Diff line number Diff line change 2626Describes a group of objects that is treated as a single instance.
2727"""
2828
29+ from abc import ABC , abstractmethod
30+ from typing import List
2931
30- class Graphic :
31- def render (self ):
32- raise NotImplementedError ("You should implement this." )
32+
33+ class Graphic (ABC ):
34+ @abstractmethod
35+ def render (self ) -> None :
36+ raise NotImplementedError ("You should implement this!" )
3337
3438
3539class CompositeGraphic (Graphic ):
36- def __init__ (self ):
37- self .graphics = []
40+ def __init__ (self )-> None :
41+ self .graphics : List [ Graphic ] = []
3842
39- def render (self ):
43+ def render (self )-> None :
4044for graphic in self .graphics :
4145graphic .render ()
4246
43- def add (self , graphic ) :
47+ def add (self , graphic : Graphic ) -> None :
4448self .graphics .append (graphic )
4549
46- def remove (self , graphic ) :
50+ def remove (self , graphic : Graphic ) -> None :
4751self .graphics .remove (graphic )
4852
4953
5054class Ellipse (Graphic ):
51- def __init__ (self , name ) :
55+ def __init__ (self , name : str ) -> None :
5256self .name = name
5357
54- def render (self ):
55- print ("Ellipse:{}" . format ( self .name ) )
58+ def render (self )-> None :
59+ print (f "Ellipse: { self .name } " )
5660
5761
5862def main ():
You can’t perform that action at this time.
0 commit comments