so I tried making a little program using classes. I have two classes, the first one is this:
class Point():
def __init__(self, x, y, z):
self.__x = x
self.__y = y
self.__z = z
def get_x(self):
return self.__x
def get_y(self):
return self.__y
def get_z(self):
return self.__z
Basically this class is about a point in the 3D Space. Now this next class, I made functions in it but I don't know how to start. How do I call the point's coordinates from the Class "Point" above? Is it something like "self.__points[i].get_x()"?
class Parcel:
def __init__(self, points):
self.__points = points
def get_area(self):
pass
def get_perimeter(self):
pass
def get_mean_elevation(self):
pass
p1 = Point(0,0,10)
p2 = Point(1,1,20)
p3 = Point(2,0,15)
points = [p1, p2, p3]
p = Parcel(points)
print p.get_area()
print p.get_perimeter()
print p.get_mean_elevation()
I haven't done the three functions(get_area and get_perimeter, get_mean_elevation) because I don't know how to summon the coordinates of the points from the list. When I use the hint given to us "self.__points[i].get_x()" to get the coordinate X from the point it doesn't work.
collections.namedtuple()class is in order.