ps2
Class DrivingRouteFormatter

java.lang.Object
  extended by ps2.RouteFormatter
      extended by ps2.DrivingRouteFormatter

public class DrivingRouteFormatter
extends RouteFormatter

The DrivingRouteFormatter class creates a textual description of directions for traversing a route that are suitable for a driver of a vehicle.

Calling computeDirections should produce directions in the following form:

Turn right onto Baker Street and go 1.2 miles.
Turn slight left onto MacGregor Street and go 0.8 miles.
Turn sharp right onto Burton street and go 2.3 miles.
Continue onto Connor Street and go 1.1 miles.

Each line should correspond to a single geographic feature of the route. In the first line, "Baker Street" is the name of the first geographical feature of the route, and "1.2 miles" is the length of the geographic feature. The length should be reported to tenth-of-a-mile precision. Each line should be terminated by a newline and should include no extra spaces other than those shown above.


Constructor Summary
DrivingRouteFormatter()
           
 
Method Summary
 String computeLine(GeoFeature geoFeature, double origHeading)
           Computes a single line of a multi-line directions String that represents the instructions for traversing a single geographical feature.
 
Methods inherited from class ps2.RouteFormatter
computeDirections, getTurnString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DrivingRouteFormatter

public DrivingRouteFormatter()
Method Detail

computeLine

public String computeLine(GeoFeature geoFeature,
                          double origHeading)

Computes a single line of a multi-line directions String that represents the instructions for traversing a single geographical feature.

Calling computeLine with a GeoFeature instance and an initial heading should produce a newline-terminated String in the following form:

Turn sharp left onto MacGregor Street and go 0.8 miles.

In the output above, "MacGregor Street" represents the name of the geographical feature, and "0.8 miles" is the length of the geographical feature. The length should be reported to tenth-of-a-mile precision. The String should be terminated by a newline and should include no extra spaces other than those shown above.

Specified by:
computeLine in class RouteFormatter
Parameters:
geoFeature - The geographical feature to traverse.
origHeading - The initial heading
Returns:
A newline-terminated String that gives directions on how to traverse this geographical feature.
Requires:
0 <= origHeading < 360