CPS 6: Assignment 3

Summer 1999

Flying Balloons and Designing Faces

Due Friday, June 4, 11:59pm

12 points

Change into your cps6 directory and create a directory called "assign3". 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 several files using the following "cp" command (don't forget the trailing period, or dot):

 cp  ~dr/cps6/assign3/*  .

This command will copy files in the directory ~dr/cps6/assign3 into your directory for you to use. If you type "ls" you should see "Makefile", "design.cc" and "fly.cc".

For each of the programming problems that follow, 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.

Problem 1: Balloons

Refer to the Balloon class in section 3.4 of your textbook for this problem.

The file "fly.cc" uses variables of type "Balloon". Right now it just declares one balloon, makes it go up, cruise, and come back down.

Modify this program to do the following sequence of actions:

  1. Create a second balloon. Right after the first balloon rises, let the second balloon rise to twice the height of the first balloon.

  2. Cause the first balloon to cruise for 1/3 of the time steps, then the second balloon to cruise for 1/3 of the time steps.

  3. Descend the second balloon 1/3 of the way down.

  4. repeat steps 2 and 3 twice more.

  5. Descend the first balloon to the ground.

Note: These measurements will not be exact as the wind will make these balloons bounce around.

Problem 2: Face Design

The file design.cc contains the code from the face program on page 42 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 (feel free to create your own styles and pick other face parts, this is your chance to be creative):

> design

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:

    @@@@@@@@@@@@@@
   @@@@@@@@@@@@@@@@
   |              |
   |              |
   |   (*)  (*)   |
   |              |
  _|              |_
 |_                _|
   |   |______|   |
   |              |

Extra Credit (2 pts): Face Design with long hair (optional)

Make a copy of the program design.cc called designX.cc. Modify designX.cc by allowing one of the options to be long hair. The long hair should be printed alongside the face, looking somewhat like the picture below. (Though you can probably come up with better looking hair than the picture below!)

Hint: Since the "long hair" option overlaps some of the options that print the parts of the face, pass a parameter to some of these functions whose value is a string of blanks (indicating long hair is not an option) or is a string representing part of the hair (indicating long hair is the prefered option).

    ||||||||||||||
  ||||||||||||||||||
  ||              ||
  ||              ||
  ||   (*)  (*)   ||
  ||              ||
  ||              ||
 |||              |||
  ||   |______|   ||
  ||              ||

Submitting Programs

When all your programs compile and produce the correct output, create a "README" file (please use all capital letters). Include your name, section number, 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 (leave off designX.cc if you did not do the extra credit).

    ~dr/bin/submit6 assign3 README fly.cc design.cc designX.cc