Project: Uninterpretable Dance
Description
In this project, you will develop a program in a file
called dance.c that makes the robot perform a randomized
dance. The program should have these features.
-
The program should contain at least five dance functions, each of
which instructs the robot to follow a different sequence of activities
(beeps and movements) in a
dance
pattern. -
The
mainfunction should make at least five calls at random to the five dance functions. The dance functions should be executed in a random order each time the program is run. - The program need not ensure that each function is called at least once for any single run of the program, but all functions should have an equal probability of being called in any program execution.
-
The program must have:
- no global variables (with the possible exception of universal constants—e.g., π, array lengths, etc.),
- at least one dance function with an array parameter,
- at least one dance function to which a value is passed as a parameter, and
-
at least one dance function to which a pointer is passed as a
parameter which is not an array:
- The function taking the pointer parameter should modify the value in a meaningful way within the function.
- The function calling this function with a pointer parameter should then be affected by the change of that variable.
-
See p. 686 in King
or the
online C reference for usage of
rand()andsrand(int). You may usetime(NULL)(requiring#include <time.h>) as the seed argument to produce a different a sequence each time the program is invoked.
General Reminders
Well-written code should should be easy to read, understand, and modify; and the code should run efficiently. In the context of this project, therefore, your program should have these characteristics:
-
There should be no redundant or unused code. For example,
- If a code segment is repeated several places, consider collecting the code in a function that is called as needed.
- If the same statements are repeated several times in a row, consider placing one copy of the statements in a loop.
-
The code should be formatted to be easily readable. For example,
- Each procedure should have comments that describe what the procedure does (including any pre- and post-conditions).
- Comments should outline the main sections within a procedure. (It is distracting for a comment to simply repeat what the code does, but it is helpful to have a high-level comment that describes the idea behind a section of code.)
-
Function, parameter, and variable names should be descriptive.
(Use variable names
b1,b2, etc. only for vitamins.) - Formatting/indenting should clarify the structure of the programs. (For example, indent consistently with in a loop and within conditional statements.)
-
The code should also be reasonably efficient. For example,
-
If variables
fooandbaralways have the same value, then one could be used throughout and the other discarded. -
If a value can be computed directly, do not use a loop. (No
need to count 1 by 1 to ten, if one can simply make the
assignment
value = 10.) - If logic seems particularly complex for one section of code, consider whether there is a simpler way.
-
If variables
Grading
In addition to the general grading guidelines for evaluation, the project is worth 26 points.
- [5 points] Dance has at least 5 creative and unique dance sequence functions
- [3 points] Dance is properly randomized
- [2 points] At least one dance function uses an array parameter
- [2 points] At least one dance function uses a pass-by-value parameter
- [6 points] At least one dance function uses a pointer parameter
- [2 points] Pointer parameter used properly
- [2 points] Value of pointer parameter changed
- [2 points] Changed pointer parameter used elsewhere in program
- [8 points] Testing
- [2 points] Test plan enumerates problem circumstances
- [3 points] Test plan lists cases with expected outcomes
- [2 points] Transcript records compilation and test runs
- [1 points] Summary statement describes outcomes and explains why the program behavior is correct
-
Comments on Program Format, Comments, Readability, etc.
(Points not given, but points can be deducted.)
