# Programmer: Sriram Pemmaraju
# Date: April 24, 2012

from point import *

class line():

    # The constructor for the line class; constructs the line segment defined by the
    # two given points p1 and p2
    def __init__(self, p1, p2):
        self.point1 = p1
        self.point2 = p2
  
    # Returns the Euclidean length of the line segment
    def length(self):
        return (self.point1).distance(self.point2)

    # Returns the slope of the line segment
    def slope(self):
        if self.point1.x == self.point2.x:
            return None

        return (self.point1.y  - self.point2.y)/(self.point1.x - self.point2.x)

    # Returns a str the represents a line segment. This function is called whenever a string representation of
    # the object is needed
    def __repr__(self):
        return "("+str(self.point1.x) + ", " + str(self.point1.y) + ")---(" + str(self.point2.x) + ", " + str(self.point2.y) + ")"
