-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLineSegment.py
More file actions
32 lines (28 loc) · 879 Bytes
/
Copy pathLineSegment.py
File metadata and controls
32 lines (28 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import Point
class LineSegment(object):
"""
Initializes a new line segment.
@param p one endpoint
@param q the other endpoint
@throws NullPointerException if either p or q is null
"""
def __init__(self, p, q):
if(p == None or q == None):
raise ValueError("argument is null")
self.p = p
self.q = q
"""
# Draws this line segment to standard draw
"""
def draw(self):
self.p.drawTo(self.q)
"""
# Returns a string representation of this line segment
# This method is provide for debugging;
# your program should not rely on the format of the string representation.
#
# @return a string representation of this line segment
"""
def __str__(self):
s = "".join( str(self.p) + " -> " + str(self.q) )
return s