This lab provides preliminary practice for creating a structured
program framework utliizing header files
#include directives and simple
functions. The project for this module will provide more extensive
practice within a more creative context.
NOTE: sound settings on your computer might be incorrectly set. Follow these instructions to troubleshoot if you are unable to hear the sound on your workstation, if you are using eSpeak commands.
For this lab, you'll develop a program comprising the following four tasks:
A sequence of beeps, involving at least 6 notes, each of which has
a specific frequency and duration. That is, tune_forward will be a
sequence of at least 6
The same sequence of
rBeepcommands used for
tune_forward, except in the reverse order.
A sequence of Scribbler 2 movements, using a combination of at
rForwardand at least 3
The same sequence of movement commands used for move_clockwise,
except that each
rTurnRightcommand is replaced by the corresponding
Note that although some tasks are related, each is largely independent from the others. Moreover, each task can be described clearly and concisely. One can think of each task conceptually at a high level, or one can delve into the lower-level details behind each task.
Although the tasks below are reasonably elementary, be sure to follow the approaches described in today's reading, including:
- placing a high-level outline within comments,
- writing stubs for procedures at an early stage of program development,
- writing code details after the high-level comments are completed,
- adding details for one procedure at a time - not all at once.
labsdirectory, write a program
procedure-practice.cwith these features:
scale-notes.h(note that one uses brackets and the other uses quotes).
Write stubs for the four separate
basic tasks outlined above (e.g.,
mainprogram should call each task procedure at least once and at least two task procedures twice.
In writing the task procedures, be sure to write the header comments before filling in the details.
In writing the
mainfunction, write the comments first to outline the work to be done. Then add the function calls.
Add details to the task procedures
procedure-practice.c, one procedure at a time—practicing the problem-solving approach of incremental and iterative program development.
Placing details for a task within a function supports two levels of abstraction (the high-level view and the details). Further levels of abstraction are possible, when one function itself utilizes more detailed functions.
As an example, define functions
tune_backward_move_counterclockwise. Each procedure should:
- call one previously-defined tune procedure,
- call one previously-define movement procedure, and
printfcallto print in a terminal window the high-level description of the work being done.
mainprogram to call various combinations of all of these procedures. Of course, the overall outline of the work should be included within comments before the procedure calls are inserted!