001 package ps4; 002 003 import ps2.GeoPoint; 004 import ps2.GeoSegment; 005 006 /** 007 * Class overview to be written by student. 008 **/ 009 public class StreetSegment extends GeoSegment { 010 011 /** 012 * Creates a new StreetSegment from the given arguments. 013 * 014 * @requires leftNumbers does not share any numbers with rightNumbers 015 * unless leftZip != rightZip; all arguments are 016 * non-null; leftZip and rightZip are valid zipcodes, 017 * where a valid zipcode is any 5-digit String or the 018 * empty String. 019 * 020 * @param p1 021 * one end of the StreetSegment 022 * @param p2 023 * the other end of the StreetSegment 024 * @param name 025 * the name of the street of which this is a segment 026 * @param leftNumbers 027 * street numbers on the left side of the street 028 * @param rightNumbers 029 * street numbers on the right side of the street 030 * @param leftZip 031 * ZIP code on the left side of the street 032 * @param rightZip 033 * ZIP code on the right side of the street 034 * @param streetClass 035 * StreetClassification of this StreetSegment 036 * @param increasingAddresses 037 * true if addresses increase from p1 to p2 038 * <p> 039 * The left and right sides of the street are as viewed from p1 040 * to p2. 041 */ 042 public StreetSegment(GeoPoint p1, GeoPoint p2, String name, 043 StreetNumberSet leftNumbers, StreetNumberSet rightNumbers, 044 String leftZip, String rightZip, StreetClassification streetClass, 045 boolean increasingAddresses) { 046 super(name, p1, p2); 047 } 048 049 /** 050 * This method assumes that the locations corresponding to street 051 * numbers on this street are spaced evenly apart (regardless of 052 * the arithmetic difference between two consecutive street 053 * numbers). It returns the fraction of the distance that the 054 * street number sn is from p1. The return value is a number from 055 * 0 to 1, exclusive. 056 * <p> 057 * For instance, if one side of this street contains the street numbers 058 * 1, 3, and 99, and this.increasingAddresses is true, then those 059 * numbers appear .25, .5, and .75 of the way along the street. If 060 * this.increasingAddresses is false, then the numbers appear .75, .5, 061 * and .25 of the way along the street. 062 * <p> 063 * If both sides of the street have the number sn (which can happen 064 * only if the two sides have different Zip codes), then this selects 065 * the address on the right-hand side of the street (as viewed from p1). 066 * 067 * @requires this instance of StreetSegment must contain the street number sn 068 * @return the fraction of the length of this segment that is from p1 to 069 * the address sn 070 */ 071 public double fractionDist(int sn) { 072 throw new RuntimeException("StreetSegment.fractionDist() unimplemented!"); 073 } 074 075 076 }