[ create a new paste ] login | about

Link: http://codepad.org/T0bXeVGk    [ raw code | fork ]

Python, pasted on Feb 8:
class ShapeSet:
    nextIndexNum = 0
    
    def __init__(self):
        """
        Initialize any needed variables
        """
        self.elements = {}

            
    def addShape(self, sh):
        """
        Add shape sh to the set; no two shapes in the set may be
        identical
        sh: shape to be added
        """

        ##verify that we have a valid shape
        if type(sh) != Circle or type(sh) != Square or type(sh) != Triangle:raise TypeError('Not a shape')
        
        if type(sh) == Circle:
            self.elements[ShapeSet.nextIndexNum] = ('Circle',sh.radius)
            ShapeSet.nextIndexNum += 1


Output:
No errors or program output.


Create a new paste based on this one


Comments: