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

homelecturesrecipeexamshwsD2Lbreeze (snow day; distance)

hw04
structs
donkey kong structs

Due:
Sep.28 (Wed) 15:00, D2L and hardcopy.
Your submitted file should be named “hw04.rkt”, plus any .java files..

Standard instructions for all homeworks:


  1. (This is the completion of qz02, from D2L.) Consider the following information, which might be part of a sports-simulation:
    A team is:
    • a name (non-empty string), AND
    • an offense rating (real number), AND
    • a defense rating (real number).

    (5pts) Give a data definition (including examples of the data, and the template for any function which processes a team), as per steps 1-3 of the design recipe. Give at least three examples of a team.

    (10pts) We'll say one team is “greater” than another if its offense is higher than the other's defense, and its defense is higher than the other's offense. Write the function team>? to implement this. Follow all the steps of the design recipe. As always, be sure to think about enough test-cases to cover the interesting situations (5 of the pts). (In this case, six or seven should suffice, if they each cover a different situation.)

  2. Familiarize yourself with the Donkey Kong arcade game. We will write a simplified version which does not need to deal with: score, sound, multiple levels, angled platforms (though that's possible as a challenge) any sort of deranged ape who throws barrels (new barrels will just appear), broken ladders, evil barrels that fall down stairs or through floors, or number-of-lives. You will need to deal with barrels that roll, jumping, and platforms.
    1. (5pts) What are three different types of things (objects) in the game, that our program will need to model?
    2. (5pts) For one of the types in (a) above give a Java class definition for it (fields and the “natural” constructor only). Create two or three instances of the class (presumably in a test method that does nothing else). You'll submit a .java file along with a .rkt file.
    3. (5pts) Repeat the previous step (b), but in racket. (That is, give a struct-definition w/ a comment indicating the field-types, and create at same two examples.) All field-names should correspond directly — e.g. if a Java field was named “numPages”, then the racket name would be “num-pages”.
    Note that we are not writing any functions, so we don't have any check-expects. We are just doing steps 1 and 2 (only) of the design recipe (in both Java and in racket), for only one of the types.
  3. Hints:


1Note that the stub-function, step 5e, gets replaced with the real body (step 7), so it won't be visible in what you submit. Also, you don't need to include the names of constructors/selectors; that was part of hw04a but not part of the design recipe.      

2 Choose one of the types above which is naturally represented as a struct/object with more than one field. (That's probably all three of those answers, though conceivably not.)      

3 The natural constructor is the one that just initializes each field directly from its arguments. It's totally automatic; in fact tools like Eclipse offer a menu option to auto-generate the natural constructor. Just like we did for Book.java in class.      

homelecturesrecipeexamshwsD2Lbreeze (snow day; distance)


©2016, Ian Barland, Radford University
Last modified 2016.Oct.31 (Mon)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Rendered by Racket.