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

homelecturesexamshwsbreeze (snow day)

hw02
book background; structs
due Sep.16 (Fri)

Due Sep.16 (Fri) (hardcopy, and on D2L) Your name and the assignment-number must be in a comment at the start of the file.

  1. (9pts) Chapter 1, Review Questions1
    1. #6
    2. #9
    3. #10
    4. #11                  can used to implement control-flow.
    5. #14 type checking parameters is important because                 
    6. #15 Aliasing is                 
  2. (3pts) Chapter 1, Problem Set 18 ((dis)advantages of two types of comments) “Our criteria” might include: readability vs writability; various costs; orthogonality vs. feature multiplicity.
  3. (2pts) Which languages might be involved in setting up an on-line order system, for a store?
    (Feel free to chat with people who have taken Software Engineering.)

  4. (6 pts) Chapter 1 gives six costs associated with a programming language. Which single cost do you think is most important for…
    1. code controlling the space shuttle launch
    2. code for a payroll program to be used by a Coca-Cola International.
    3. code for a scientific simulation of proteins in a cell, to help develop new drugs.
    4. code to compute what percentage of RU students have more than one picture on their RU home web page. (Suppose that a friend is writing a report for a Media Studies project, and wants to include this statistic.)
    5. Code for maintaining all aspects of a course gradebook (entering and editing information, adding new features on demand like “replace-lowest-hw-with-exam-percentage”, generating web-views for instructor and students, adding new features to the web-views as requested, etc.).
    (Just give the name of the category, e.g. “compiling programs”.)

    Which of the five example programs above is most “typical” do you think, of the sort of programs most programmers tend to work on?

The following questions relate to the beginning stages of designing an Asteroids-like game.

  1. (15pts) (For this problem, you'll submit two files: a .java and .rkt program file. Make these separate files from the answers above.)
    We start by representing the player's ship, and writing a method involving them.
    1. Give a Java class to represent a ship (non-static fields and constructor only). Note that no images are involved. (For every field, give a two-to-three word description of what it stands for, and its units.)
    2. Give some Java statements which create two different Ship objects
    3. Give a corresponding Racket define-struct statement.
      1. What is the signature of of the constructor which racket creates for you?
        (A function's signature is its name, along with the types of its parameters and its return type. For example, the signature of substring is substring : string, int, int → string and the signature of addition is + : number, number → number.
      2. (2pts) Give two examples of calling the constructor, corresponding to your the two Java examples.
      3. What is the name and signature of one of the ship accessor functions which racket creates for you?
  2. future

    The following problems will be on future homeworks. They are not to be turned in now, but if you want to get an early start, go ahead!

  3. The static Java method move will which takes in a Ship, and returns a whole new (different!) Ship object which has traveled for one unit of time (a "tick").
    1. Write a stub method.
    2. Write two test cases. (You'll need to print out the actual and expected results of calling your method; presumably2 you'll want to write a toString to help with this.) You can put those test cases in Truck.main.
    3. After writing the test cases and getting them to compile, now complete the method.
    You should have a single .java file (which compiles and runs); it should be less than a page of well-spaced, commented code.
  4. In your racket version, write the corresponding move-ship function (including test-cases of course, presumably using check-expect).
  5. Continue your racket version by implementing a struct for asteroids. (Hint: Give it a shorter name, something like “stroid”.)
  6. Write a function draw-ship which takes in a ship and an image (the screen / background), and returns a new image which contains [a picture of] the ship overlayed on the given background. Include test cases, before writing the code!

    Look in the racket documentation for helpful image-drawing functions. (Either search directly, or take a function you know about (like circle), put the caret over it, and hit F1 to call up the documentation.)

  7. Write draw-stroid.

1 Short correct answers get more credit than long correct answers; use a single word when possible.      

2 If you want to be fancier than just printing out results, you can use JUnit tests. This will require overriding equals.      

homelecturesexamshwsbreeze (snow day)


©2011, Ian Barland, Radford University
Last modified 2011.Oct.20 (Thu)
Please mail any suggestions
(incl. typos, broken links)
to ibarlandradford.edu
Powered by PLT Scheme