(Feb-15-2019, 10:39 AM)buran Wrote: Fix your classes, before you do the random/grid part. For the inheritance part - take a look at this https://www.pythonforbeginners.com/super...r-function
One problem with your code as it is now - you need to pass all the necessary information when instantiate triangle or sphere (i.e. instance of the class). I mean all the information - that is, not only width, height, length or radius, but also x, y, and penalty, but also the information for the parent class - x, y and penalty. Then you will use x, y, and penalty to initialize the parent class.
class Shape:
def__init__(self,x,y,penalty):
self.x=x
self.y=y
self.penalty=penalty
class Triangle(Shape):
def__init__(self,width,height,lengh):
super().__init__(x,y,penalty)
class Sphere(Shape):
def__int__(self,radius):
super().__init__(x,y,penalty)
that's what you mean??