@Assignments/hw7(week8)/hw7.rb
# *add* methods to this class -- do *not* change given code and do not
# override any methods
# Note: This is the most difficult class.  In the sample solution,
#  preprocess_prog is about 15 lines long and 
# intersectWithSegmentAsLineResult is about 40 lines long
add* methods to this class -- do *not* change given code and do not
override any methods
Note: This is the most difficult class.  In the sample solution,
preprocess_prog is about 15 lines long and
intersectWithSegmentAsLineResult is about 40 lines long
add * methods to this class -- do * not * change given code and do not override any methods Note : This is the most difficult class . In the sample solution preprocess_prog is about 15 lines long and intersectWithSegmentAsLineResult is about 40 lines long
def intersectWithSegmentAsLineResult seg
    if x1 > seg.x2 or x2 < seg.x1 then NoPoints.new
    elsif real_close(x1, seg.x2) then Point.new(x1,y1)
    elsif real_close(x2, seg.x1) then Point.new(x2,y2)
    else
      if x1 < seg.x1 then
        fp = Point.new(x1,y1)
      else
        fp = Point.new(seg.x1, seg.y1)
      end
      if x2 < seg.x2 then
        sp = Point.new(x2,y2)
      else
        sp = Point.new(seg.x2, seg.y2)
      end
      LineSegment.new(fp.x, fp.y, sp.x, sp.y)
    end
  end
def intersectWithSegmentAsLineResult seg if x1 > seg . x2 or x2 < seg . x1 then NoPoints . new elsif real_close ( x1 , seg . x2 ) then Point . new ( x1 , y1 ) elsif real_close ( x2 , seg . x1 ) then Point . new ( x2 , y2 ) else if x1 < seg . x1 then fp = Point . new ( x1 , y1 ) else fp = Point . new ( seg . x1 , seg . y1 ) end if x2 < seg . x2 then sp = Point . new ( x2 , y2 ) else sp = Point . new ( seg . x2 , seg . y2 ) end LineSegment . new ( fp . x , fp . y , sp . x , sp . y ) end end
add* methods to this class -- do *not* change given code and do not
override any methods
Note: This is the most difficult class.
add * methods to this class -- do * not * change given code and do not override any methods Note : This is the most difficult class .
seg