-
Notifications
You must be signed in to change notification settings - Fork 0
/
RouteFormatter.java
67 lines (58 loc) · 2.32 KB
/
RouteFormatter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package homework1;
/**
* A RouteFormatter class knows how to create a textual description of
* directions from one location to another. The class is abstract to
* support different textual descriptions.
*/
public abstract class RouteFormatter {
/**
* Give directions for following this Route, starting at its start point
* and facing in the specified heading.
* @requires route != null &&
* 0 <= heading < 360
* @param route the route for which to print directions.
* @param heading the initial heading.
* @return A newline-terminated directions <tt>String</tt> giving
* human-readable directions from start to end along this route.
**/
public String computeDirections(Route route, double heading) {
// Implementation hint:
// This method should call computeLine() for each geographic
// feature in this route and concatenate the results into a single
// String.
// TODO Implement this method
}
/**
* Computes a single line of a multi-line directions String that
* represents the instructions for traversing a single geographic
* feature.
* @requires geoFeature != null
* @param geoFeature the geographical feature to traverse.
* @param origHeading the initial heading.
* @return A newline-terminated <tt>String</tt> that gives directions
* on how to traverse this geographic feature.
*/
public abstract String computeLine(GeoFeature geoFeature, double origHeading);
/**
* Computes directions to turn based on the heading change.
* @requires 0 <= oldHeading < 360 &&
* 0 <= newHeading < 360
* @param origHeading the start heading.
* @param newHeading the desired new heading.
* @return English directions to go from the old heading to the new
* one. Let the angle from the original heading to the new
* heading be a. The turn should be annotated as:
* <p>
* <pre>
* Continue if a < 10
* Turn slight right if 10 <= a < 60
* Turn right if 60 <= a < 120
* Turn sharp right if 120 <= a < 179
* U-turn if 179 <= a
* </pre>
* and likewise for left turns.
*/
protected String getTurnString(double origHeading, double newHeading) {
// TODO Implement this method
}
}