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

homelecturesrecipeexamshwsD2Lbreeze (snow day; distance)

hw04b
structs
space invader structs

Due:
Section 01: Sep.28 (Mon) 14:00, on D2L and hardcopy in class
Section 11: Sep.29 (Tue) 23:59, D2L.
Your submitted file should be named “hw04b.rkt”.

Standard instructions for all homeworks:


  1. (This is the completion of hw04a, from D2L.) Consider the following information, which might be part of a sports-simulation.

    A team is:

    (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 recipe1. 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 Space Invaders arcade game, such as at kongregate.com. We will write a simplified version which does not need to deal with: score, multiple waves (levels), enemy shots (though I encourage it), sound, different types of enemies, flying saucers, or number-of-lives.
    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) above2 give a Java class definition for it (fields and the “natural” constructor3 only). Create two or three instances of the objectclass (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:

See also scheme-resources—ITEC380 Racket resources.


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)


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