R
Rui Maciel
Let:
- class Point be a data type which is used to define points in space
- class Line be a data type which possesses an aggregate relationship with
objects of type Point
- class Model be a container class which stores collections of Point and
Line objects
Essentially, a Model object stores lists of Point objects and Line objects,
and Line objects include references to Point objects which represent the
starting and ending point of a line.
To reflect this class relationship, I've defined the following classes:
<code>
class Point:
position = []
def __init__(self, x, y, z = 0):
self.position = [x, y, z]
class Line:
points = ()
def __init__(self, p_i, p_f):
self.points = (p_i, p_f)
class Model:
points = []
lines = []
</code>
It would be nice if, whenever a Point object was updated, the Line objects
which are associated with it could reflect those updates directly in
Line.p_i and Line.p_f.
What's the Python way of achieving the same effect?
Thanks in advance,
Rui Maciel
- class Point be a data type which is used to define points in space
- class Line be a data type which possesses an aggregate relationship with
objects of type Point
- class Model be a container class which stores collections of Point and
Line objects
Essentially, a Model object stores lists of Point objects and Line objects,
and Line objects include references to Point objects which represent the
starting and ending point of a line.
To reflect this class relationship, I've defined the following classes:
<code>
class Point:
position = []
def __init__(self, x, y, z = 0):
self.position = [x, y, z]
class Line:
points = ()
def __init__(self, p_i, p_f):
self.points = (p_i, p_f)
class Model:
points = []
lines = []
</code>
It would be nice if, whenever a Point object was updated, the Line objects
which are associated with it could reflect those updates directly in
Line.p_i and Line.p_f.
What's the Python way of achieving the same effect?
Thanks in advance,
Rui Maciel