So I'm new to python, but i've programmed in java a bit. For class our teacher is having us create a line segment (purely textual, not visual). He has supplied us with the Point abstract data type, and we must use it to create a line segment abstract data type. Now I know that relying on everyone here to code this for me would be cheating, but I was wondering if you could just help me with my constructor, I can't seem to get it to work. Every time I try and create a 'linesegment' I get "name 'LineSegment' is not defined" Please help, below is a bit of my code.
import carpoint #This is where the point class is imported
class LineSegment :
def __init__(self, pointA, pointB):
self._firstPoint = pointA
self._endPoint = pointB
So when I try:
lineseg1 = LineSegment(Point(3,3),Point(1,1))
It tells me that LineSegment is undefined.
Please help, I'm not sure what I'm doing wrong
Thanks!

New Topic/Question
Reply



MultiQuote




|