Skip to main content Link Menu Expand (external link) Copy Copied

Notes

  1. Complete this assignment solo. Partnered work will begin with the next assignment.

  2. You must follow all steps of the design recipe for every part of the assignment.

  3. Your test cases must cover all lines of code, with the exception of templates. i.e., you cannot have any “Halloween colors” in your code (excluding templates).

String Processing

  1. Design a function called concat-longer-first that consumes two strings and produces a single string that concatenates them, with a space between them. However, in this result, the first string should be the longer of the two. Ensure you follow all steps of the design recipe, and include three distinct check-expects.

The Canadian

The VIA Rail Canadian is a sleeper train that runs from Vancouver to Toronto. It is also featured on the Canadian $10 bill.

  1. Look up the list of stops the Canadian makes in the brochure, and write a data definition called CanadianTrainStop that can represent any of these stops.

  2. Design a function called province to determine the province in which a stop is located.

  3. Some stops on the Canadian connect to other train lines. Write a predicate called can-transfer? that produces #true when a stop has an available transfer to another line. You may shorten your function definition if you find it convenient to do so.

Compass

  1. Write a data definition called CompassDirection that represents a single cardinal or inter-cardinal direction that appears on a compass rose.

  2. Write a predicate called cardinal? to determine if a CompassDirection is a cardinal direction (and not an inter-cardinal direction).

  3. Write a function called opposite that consumes a CompassDirection and produces the opposite direction.

Rotten Tomatoes

A movie review website, such as Rotten Tomatoes, lists a list of information about each movie, including its name, its Tomatometer, and MPAA rating.

  1. Design a a new data definition called Movie which contains these three pieces of information.

  2. Finding a movie to watch is tricky. Design a predicate called can-and-will-watch? that consumes a Movie and the viewer’s age. The predicate should should produce #true if and only if the movie is age-appropriate and not “Rotten”.

  3. Rotten Tomatoes summarizes each movie in an info panel that looks like this:

    Info panel of Ferris Beuller's Day Off from Rotten Tomatoes

    Using 2htdp/image library, write a function called movie->image to draw a similar info-panel given a movie. You can be creative, and you only need to display the information that you have in your Movie data definition.