RU beehive logo ITEC dept promo banner
ITEC 380
2017fall
ibarland

homelecturesrecipeexamshwsD2Lbreeze (snow day; distance)

union-types
working with a union type
hw03b

Due: Sep.25 (Mon) 15:00 (hardcopy and D2L)
(but try to have it mostly-completed by Friday evening)
Your submitted file should be named “hw03.rkt”.
Note: There are also some D2L questions under a quiz named “hw03a”.

We wish to write code about whether or not the Radford Highlanders won their soccer game, this last weekend. We want to capture whether: they won/lost, or tied, or there wasn't any game this weekend, or (if the game is still in-progress) what the name of the team currently being played is.

  1. (5pts) Complete steps 1-3 of the-design-recipe—the design recipe: final version for representing this information, which we'll name “game-result”.
    Hint: To represent whether they won or lost, a boolean seems appropriate. What types seem appropriate for each of the other variants?
  2. (5pts) Write a function payout which takes in the amount of a bet1 placed that the Highlanders’ would win their game (non-negative) and a game-result and returns how much money is to be repaid:
  3. (5pts) Write a function game-result->string which returns a user-friendly message similar to one of the following, as appropriate: (You will, of course, follow the applicable steps 4,5,7,8 of the-design-recipe—the design recipe: final version.)

Standard instructions for all homeworks (unless instructed otherwise):


1A perfectly perfecty legal bet on a game of skill, with no luck involved whatsoever.      
2 The only exception to open-paren-preceded-by-space (or, at the start of a line) is any “[(”s occuring in a cond. Though we'll have a few other exceptions in the future: let* expressions, and (very occasionally) when calling higher-order functions.      

homelecturesrecipeexamshwsD2Lbreeze (snow day; distance)


©2017, Ian Barland, Radford University
Last modified 2017.Sep.23 (Sat)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.