Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

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)
See more answers at brainly.com
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.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

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
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.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

Not the answer you are looking for?

Search for more explanations.

Ask your own question