![]()

Objectives | Options | Staff&Contact Information | Where&When | Textbook | Grading | Policies | Schedule&Assignments | Accelerated Track
An interactive directions application suggests travel routes using a combination of walking, trains, buses, and taxis. To help users choose suitable routes, the application asks users questions about their constraints and travel preferences. After asking a question, the application gives a sequence of travel instructions, perhaps ending in another question as needed to plan the next travel segment. The application uses the following data definitions, illustrated in the subsequent example for traveling between Boston and WPI.
; A question is (make-question string steplist steplist) (define-struct question (text yes no)) ; A steplist is ; - (cons question empty) ; - (cons instruction empty) ; - (cons instruction steplist) ; An instruction is one of: ; - (make-walk-to string number number) ; - (make-train-to string number number) ; - (make-bus-to string number number) ; - (make-taxi-to string number number number) ; - (make-purchase string number) (define-struct walk-to (where lat long)) (define-struct train-to (where lat long)) (define-struct bus-to (where lat long)) (define-struct taxi-to (where lat long expected-price)) (define-struct purchase (item expected-price))
(define south-station-to-wpi
(make-question "Are you a long-distance hiker?"
(list (make-walk-to "WPI" 42.274334 -71.80822))
(list (make-purchase "MBTA zone 8 ticket" 7.75)
(make-train-to "Worcester" 42.261793 -71.793703)
(make-taxi-to "WPI" 42.274334 -71.80822 7))))
(define logan-to-WPI
(make-question "Do you have a lot of luggage?"
(list (make-taxi-to "WPI" 42.274334 -71.80822 100))
(list (make-question "Do you like public transit?"
(list (make-walk-to "Logan Silver Line Station" 42.366777 -71.017366)
(make-purchase "Charlie ticket" 2.25)
(make-bus-to "South Station" 42.352767 -71.055572)
south-station-to-wpi)
(list (make-walk-to "Logan Taxi Stand" 42.366422 -71.017201)
(make-taxi-to "South Station" 42.352767 -71.055572 20)
south-station-to-wpi)))))
(define logan-to-WPI
(make-question "Do you have a lot of luggage?"
(list (make-taxi-to "WPI" 42.274334,-71.80822 100))
(make-question "Do you like public transit?"
(list (make-walk-to "Logan Silver Line Station" 42.366777 -71.017366)
...)
(list (make-walk-to "Logan Taxi Stand" 42.366422 -71.017201) ...))))
In a separate file, provide a class definition for the data definition modified
to accommodate this change. Specifically, the yes/no parts of a question can now
contain a single question, a list of instructions, or a list of instructions with
a single question at the end of the list (as in the current definition). You do
not need to write any methods for this part.
Turning is at https://turnin.cs.wpi.edu:8088/servlets/turnin.ss
Remember, the deadline is Monday, November 2, 2009 at 11:59 PM.
The deadline to drop from the accelerated option is 24 hours after the homework deadline, Tuesday, November 3, 2009 at 11:59 PM. If you found the homework difficult and you want to drop, e-mail me. If you're not sure whether to stay or not, e-mail me as well. My e-mail is gmarceau at cs.wpi.edu
