anonymous
  • anonymous
I'm stuck on the tetrominoes. I didn't understand this piece of code 'Shape.__init__(self, coords, "blue")' because it isn't being assigned to any attribute. For example, in the Block class, I've assigned the Rectangle object to the 'it' attribute, which allowed me to further set the color of the block. "self.it = Rectangle(self, p1, p2) self.it.setFill(self, color)" But how can I set its color initializing with 'Rectangle.__init__(self, p1, p2, color)'?
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW)
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Get this expert

answer on brainly

SEE EXPERT ANSWER

Get your free account and access expert answers to this
and thousands of other questions

anonymous
  • anonymous
you define a class class X: def __init__(self, color): # this allows you to set the self.color = color # color when you create an X object now, when you create a member of the class, you can set it's color at the same time: bob = X(red) #: create a red X object called bob the def __init__(self,color) allows you to set the color with X(red) rather than: bob = X() # without the def __init__ bob.color = 'red' # you would do this
anonymous
  • anonymous
Block IS A Rectangle and as part of the Block __init__ you need to calculate the corner points, invoke the Rectangle __init__ and then fill with the specified color. On the other hand, Shape HAS one or more Blocks. You won't explicitly create a Shape object. It will serve as a parent to a child object of a particular shape (I_shape for example) which will specify the list of coordinates (relative to the center) and the color.

Looking for something else?

Not the answer you are looking for? Search for more explanations.