ps4
Class StreetSegment

java.lang.Object
  extended by ps2.GeoSegment
      extended by ps4.StreetSegment

public class StreetSegment
extends GeoSegment

Class overview to be written by student.


Constructor Summary
StreetSegment(GeoPoint p1, GeoPoint p2, String name, StreetNumberSet leftNumbers, StreetNumberSet rightNumbers, String leftZip, String rightZip, StreetClassification streetClass, boolean increasingAddresses)
          Creates a new StreetSegment from the given arguments.
 
Method Summary
 double fractionDist(int sn)
          This method assumes that the locations corresponding to street numbers on this street are spaced evenly apart (regardless of the arithmetic difference between two consecutive street numbers).
 
Methods inherited from class ps2.GeoSegment
equals, getHeading, getLength, getName, getP1, getP2, hashCode, reverse, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StreetSegment

public StreetSegment(GeoPoint p1,
                     GeoPoint p2,
                     String name,
                     StreetNumberSet leftNumbers,
                     StreetNumberSet rightNumbers,
                     String leftZip,
                     String rightZip,
                     StreetClassification streetClass,
                     boolean increasingAddresses)
Creates a new StreetSegment from the given arguments.

Parameters:
p1 - one end of the StreetSegment
p2 - the other end of the StreetSegment
name - the name of the street of which this is a segment
leftNumbers - street numbers on the left side of the street
rightNumbers - street numbers on the right side of the street
leftZip - ZIP code on the left side of the street
rightZip - ZIP code on the right side of the street
streetClass - StreetClassification of this StreetSegment
increasingAddresses - true if addresses increase from p1 to p2

The left and right sides of the street are as viewed from p1 to p2.

Requires:
leftNumbers is disjoint from rightNumbers && all arguments are non-null
Method Detail

fractionDist

public double fractionDist(int sn)
This method assumes that the locations corresponding to street numbers on this street are spaced evenly apart (regardless of the arithmetic difference between two consecutive street numbers). It returns the fraction of the distance that the street number sn is from p1. The return value is a number from 0 to 1, exclusive.

For instance, if one side of this street contains the street numbers 1, 3, and 7, and this.increasingAddresses is true, then those numbers appear .25, .5, and .75 of the way along the street. If this.increasingAddresses is false, then the numbers appear .75, .5, and .25 of the way along the street.

Returns:
the fraction of the length of this segment that is from p1 to the address sn
Requires:
this instance of StreetSegment must contain the street number sn