CS 1101 - Aterm 16

Lab 1 - Testing programs; using cond

Tuesday/Wednesday, August 30/August 31

Preliminaries

Sign the attendance sheet.

Problem description

The dates of the astronomical seasons vary from year to year and from location to location. For Worcester this year, the seasons are as follows:

Develop a function called season that consumes a month (as a String) and a day (a Natural). The function produces the season (a String) for that date. The Design Recipe steps for developing a function are

  1. write a signature/purpose for the function
  2. write test cases for the function, using check-expect
  3. write the function definition
  4. run the tests

What you should do

  1. Write the signature and purpose for the season function.

  2. Write a set of test cases for the season function. Remember that you should be writing test cases against the signature/purpose of the function, not against any particular implementation of the function. Another way to say this is that you write test cases before you write the function definition; all you have to go on when you develop tests are the signature/purpose. (For this problem, you may also assume you know the dates of each season, as given in the description above.)

    After you finish problem 2, ask one of the lab assistants to check over your work to make sure you're on the right track. Did you have enough test cases?

  3. Write the function definition for season. Use cond in your solution (not if). If you're not sure how to use cond, re-view yesterday's video assignment (02 HtDD - 1 - cond Expressions) on the Youtube video channel.

  4. Run your function against your tests. If all your tests pass, turn in your program (see "What to Turn In", below), and try these animation exercises for fun. If not all of your tests passed, determine where the problem lies (it could be in the test cases, or it could be in the function itself). Fix what's wrong, and try again.

What to Turn In

If you didn't get the season function to run correctly, don't worry; you may complete it on your own time. Today you should turn in whatever you've completed at the end of the 50-minute lab period.

Using InstructAssist, turn in a single file containing the work you completed during the lab. The name of the project is Lab 1. The name of the file should be yourLastName-lab1.