Notes
-
Complete this assignment solo. Partnered work will begin with the next assignment.
-
You must follow all steps of the design recipe for every part of the assignment.
-
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
- 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.
-
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. -
Design a function called
province
to determine the province in which a stop is located. -
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
-
Write a data definition called
CompassDirection
that represents a single cardinal or inter-cardinal direction that appears on a compass rose. -
Write a predicate called
cardinal?
to determine if aCompassDirection
is a cardinal direction (and not an inter-cardinal direction). -
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.
-
Design a a new data definition called Movie which contains these three pieces of information.
-
Finding a movie to watch is tricky. Design a predicate called
can-and-will-watch?
that consumes aMovie
and the viewer’s age. The predicate should should produce#true
if and only if the movie is age-appropriate and not “Rotten”. -
Rotten Tomatoes summarizes each movie in an info panel that looks like this:
Using
2htdp/image
library, write a function calledmovie->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 yourMovie
data definition.