CO311: Introduction to Modern Programming II

Lab Practical #3: February 14, 2000

You will be randomly assigned one of two exercises to re-write. In both cases, you should start by copying the “final solution” from the website at http://teach.millard.org/co311/solutions/3_22/step7.htm. Both solutions will ask you to modify the existing code to add new functionality. Please read the entire problem before jumping into the code!

  1. Modify the DrawCheckerboard() function to let the calling function (your “driver program”) determine the number of colums and rows for the checkerboard. In addition, you should also modify the function so that it will draw the checkerboard using 1cm boxes (instead of 2cm) and alternating between green and yellow (instead of blue and red). The upper-left box in all  checkerboards should be green.
  2. Modify the DrawCheckerboard() function to let the calling function (your “driver program”) determine the two colors used for the alternating boxes. To make it easier, you should take advantage of the numeric-equivalence of the enum data type:
    enum color { Black, White, Red, Green, Blue, Yellow, Cyan, Magenta };
    is equivalent to
    int Black = 0;
    int White = 1;
    int Red = 2;
    int Green = 3;
    int Blue = 4;
    int Yellow = 5;
    int Cyan = 6
    int Magenta = 7;

    This means that you can prompt the user for two ints to specify the colors (with an appropriate legend for picking colors), instead of reading and parsing text names into the enumerated type. In all cases, the first color entered must be the upper-left box of the checkerboard.
    In addition, you should also modify the function so that it will draw an 8×8 checkerboard (instead of 4×4) using 1cm blocks (instead of 2cm). 

You must make the proper changes to prototypes and parameters and provide an appropriate driver/test program for the functions.

Submit the finished CPP file to the FTP site in its own folder called P3.

You will have 45 minutes to complete the assignment.