Totem Poles
Due: Tuesday, Sept. 26, 8am
12 points
Change into your cps6 directory using the "cd" command and create another directory called "assign3" using the "mkdir" command. Change into the "assign3" directory. If you did this correctly, when you type "pwd" you should see a long path name that ends with "/cps6/assign3"
In order to do this assignment, you need to copy files using the following "cp" command (don't forget the trailing period, or dot):
~ola/cps6/assign3/* .
This command will copy the files in the directory ~ola/cps6/assign3 into your directory for you to use. If you type "ls" you should see "Makefile" and "sketch.cc".
For the following programming problems, you should use the style rules discussed in class, which includes meaningful variable names, indentation, and comments at the top of the file and for each function.
Part 1: Police Sketch Program
The sketch.cc file contains the code from the parts.cc file on page 35 and 36 of your textbook. Modify this program to create a sketch of a face in which a user is given choices for hair type, eye style, mouth style, etc. and the program prints out the face based on the users choices.
Your program should ask the user for at least three choices for each of at least three face parts. A sample run might be:
> sketch
Choices of hair style
1) parted
2) curly
3) balding
Enter choice: 2
Choices of eye style
1) beady eyed
2) wears glasses
3) wide eyed
Enter choice: 3
Choices of mouth style
1) smile
2) frown
3) surprised
Enter choice: 1
Your suspect looks like:
@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@
| |
| |
| (*) (*) |
| |
_| |_
|_ _|
| |______| |
| |
Part 2
Write a program named "totem.cc" that draws a ``random'' totem-pole of faces. The height of the pole, measured in faces, should be specified by the user. For example, a sample run below shows a totem-pole of height 2.
> totem
how many faces: 2
|||||||/////////
| |
| |
| O O |
| |
_| |_
|_ _|
| -------- |
| |
||||||||||||||||
| |
| |
| . . |
| |
_| |_
|_ _|
| |______| |
| |
Each ``head'' in the totem pole should be random in the sense that there must be at least three parts to a head, and these should be chosen at random. For example, the function below shows one example of random hair.
void
Hair()
// postcondition: prints random hair
{
Dice d(3);
int choice = d.Roll();
if (1 == choice){
cout << " |||||||///////// " << endl;
}
else if (2 == choice){
cout << " |||||||||||||||| " << endl;
}
else if (3 == choice){
cout << " |______________| " << endl;
}
Sides();
}
Be sure that you use appropriate "Dice" objects, i.e., if there are three different hair styles a three sided die should be used.
You should have at least three different parts to a head (e.g., hair, eyes, nose, mouth) and, for each part, at least three choices.
Submitting Programs
When your programs for Parts 1 and 2 compile and produce the correct output, create a "README" file (please use all capital letters). Include your name, the date, and an estimate of how long you worked on the assignment in the "README" file. You must also include a list of names of all those people with whom you collaborated on the assignment.
To submit your programs electronically type
submit6 assign3 sketch.cc totem.cc README
You should receive a message telling you that the programs were submitted correctly. If it doesn't work try typing ~ola/bin/submit6 in place of submit6 above.