Package turtle

Class LineSegment

java.lang.Object
turtle.LineSegment

public class LineSegment
extends Object
An immutable line segment in pixel space.

PS0 instructions: do NOT change this class.

  • Constructor Details

    • LineSegment

      public LineSegment​(double startx, double starty, double endx, double endy, PenColor color)
      Construct a line segment from coordinate pairs.
      Parameters:
      startx - x-coordinate of start point
      starty - y-coordinate of start point
      endx - x-coordinate of end point
      endy - y-coordinate of end point
      color - line segment color
    • LineSegment

      public LineSegment​(Point start, Point end, PenColor color)
      Construct a line segment from start and end points.
      Parameters:
      start - one end of the line segment
      end - the other end of the line segment
      color - line segment color
  • Method Details

    • start

      public Point start()
      Returns:
      starting point of the line segment
    • end

      public Point end()
      Returns:
      ending point of the line segment
    • color

      public PenColor color()
      Returns:
      color of the line segment
    • length

      public double length()
      Compute the length of this segment.
      Returns:
      the length of the line segment
    • equals

      public boolean equals​(Object that)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object