001    package ps2;
002    
003    import java.util.*;
004    
005    
006    /**
007     * <p>
008     * A Route is a path that traverses arbitrary GeoSegments, regardless
009     * of their names.
010     * </p>
011     *
012     * <p>
013     * Routes are immutable.  New Routes can be constructed by adding a
014     * segment to the end of a Route.  An added segment must be properly
015     * oriented; that is, its p1 field must correspond to the end of the
016     * original Route, and its p2 field corresponds to the end of the new
017     * Route.
018     * </p>
019     *
020     * <p>
021     * Because a Route is not necessarily straight, its length -- the
022     * distance traveled by following the path from start to end -- is not
023     * necessarily the same as the distance along a straight line between
024     * its endpoints.
025     * </p>
026     *
027     * <p>
028     * Lastly, a Route may be viewed as a sequence of geographical
029     * features, using the <tt>getGeoFeatures()</tt> method which returns
030     * a List<GeoFeature>.
031     * </p>
032     *
033     * @specfield start : GeoPoint         // location of the start of the route
034     * @specfield end : GeoPoint           // location of the end of the route
035     * @specfield startHeading : angle     // direction of travel at the start of the route, in degrees
036     * @specfield endHeading : angle       // direction of travel at the end of the route, in degrees
037     * @specfield geoFeatures : sequence   // a sequence of geographic features that make up this Route
038     * @specfield geoSegments : sequence   // a sequence of segments that make up this Route
039     * @derivedfield length : real         // total length of the route, in miles
040     * @derivedfield endingGeoSegment : GeoSegment   // last GeoSegment of the route
041     **/
042    public class Route {
043        //FIELDS
044    
045    
046        // Constructors
047    
048        /**
049         * @requires gs != null
050         * @effects Constructs a new Route.
051         **/
052        public Route(GeoSegment gs) {
053            throw new RuntimeException("Not yet implemented");
054        }
055    
056    
057        /**
058         * Checks that the representation invariant holds (if any).
059         **/
060        // Throws a RuntimeException if the rep invariant is violated.
061        private void checkRep() throws RuntimeException {
062            throw new RuntimeException("Not yet implemented");
063        }
064    
065    
066        // Observers
067    
068        /**
069         * @return location of the start of the route
070         **/
071        public GeoPoint getStart() {
072            throw new RuntimeException("Not yet implemented");
073        }
074    
075    
076        /**
077         * @return location of the end of the route
078         **/
079        public GeoPoint getEnd() {
080            throw new RuntimeException("Not yet implemented");
081        }
082    
083        /**
084         * @return the last GeoSegment of the route
085         **/
086        public GeoSegment getEndingGeoSegment() {
087            throw new RuntimeException("Not yet implemented");
088        }
089    
090    
091        /**
092         * @return direction (in compass heading) of travel at the start
093         * of the route, in degrees
094         **/
095        public double getStartHeading() {
096            throw new RuntimeException("Not yet implemented");
097        }
098    
099    
100        /**
101         * @return direction of travel at the end of the route, in
102         * degrees
103         */
104        public double getEndHeading() {
105            throw new RuntimeException("Not yet implemented");
106        }
107    
108    
109        /**
110         * @return total length of the route, in miles.  NOTE: this is NOT
111         * as-the-crow-flies, but rather the total distance required to
112         * traverse the route.  These values are not necessarily equal.
113         */
114        public double getLength() {
115            throw new RuntimeException("Not yet implemented");
116        }
117    
118    
119        // Producers
120    
121        /**
122         * Creates a new route that is equal to this route with gs
123         * appended to its end.
124         * @requires gs != null && gs.p1 = this.end
125         * @return a new Route r such that
126         *       r.end = gs.p2
127         *    && r.endHeading = gs.heading
128         *    && r.length = this.length + gs.length
129         **/
130        public Route addSegment(GeoSegment gs) {
131            throw new RuntimeException("Not yet implemented");
132        }
133    
134    
135        /**
136         * Returns a List of GeoFeature objects.  The
137         * concatenation of the GeoFeatures, in order, is equivalent to
138         * this route.  No two consecutive GeoFeature objects have the
139         * same name.<p>
140         *
141         * @return a List of GeoFeatures such that
142         * <pre>
143         *      this.start        = a.get(0).start
144         *   && this.startHeading = a.get(0).startHeading
145         *   && this.end          = a.get(a.length - 1).end
146         *   && this.endHeading   = a.get(a.length - 1).endHeading
147         *   && this.length       =  sum (0 &lt;= i &lt; a.size) . a.get(i).length
148         *   && for all integers i .
149         *          (0 &lt;= i &lt; a.size - 1 =&gt; (a.get(i).name != a.get(i+1).name &&
150         *                                       a.get(i).end   = a.get(i+1).start))
151         * </pre>
152         * @see ps2.GeoFeature
153         **/
154        public List<GeoFeature> getGeoFeatures() {
155            throw new RuntimeException("Not yet implemented");
156        }
157    
158    
159        /**
160         * Returns a List of GeoSegment objects.  The concatentation
161         * of the GeoSegments, in order, is equivalent to this route.
162         * @return a List of GeoSegments such that
163         * <pre>
164         *      this.start        = a.get(0).p1
165         *   && this.startHeading = a.get(0).heading
166         *   && this.end          = a.get( a.size - 1 ).p2
167         *   && this.endHeading   = a.get( a.size - 1 ).heading
168         *   && this.length       =  sum (0 &lt;= i &lt; a.size) . a.get(i).length
169         *
170         * </pre>
171         * @see ps2.GeoSegment
172         */
173        public List<GeoSegment> getGeoSegments() {
174            throw new RuntimeException("Not yet implemented");
175        }
176    
177    
178        /**
179         * Compares the specified Object with this Route for equality.
180         * @return true iff (o instanceof Route)
181         *         && (o.geoFeatures and this.geoFeatures contain
182         *             the same elements in the same order).
183         **/
184        public boolean equals(Object o) {
185            throw new RuntimeException("Not yet implemented");
186        }
187    
188    
189        /**
190         * @return a valid hash code for this.
191         **/
192        public int hashCode() {
193            // This implementation will work, but you may want to modify
194            // it later for improved performance.  If you do change the
195            // implementation, make sure it satisfies the hashCode
196            // invariant.  That is, if equals returns true for two
197            // objects, then they must have the same hashCode.
198    
199            return (1);
200        }
201    
202    
203        /**
204         * @return a string representation of this.
205         **/
206        public String toString() {
207            throw new RuntimeException("Not yet implemented");
208        }
209    
210    } //Route