If the directory called C:\FILES\Lab09 presently exists on your computer, delete it.
You get two projects to start the lab. Download a ZIP'ed copy of the Lab 9 projects and store it in the C:\FILES directory.
Use PowerZip to open this archive and then to extract the files to the C:\FILES directory. This should create a new directory called Lab09 with two subdirectories:
Start up Visual C++ and open the workspace c:\files\Lab09\Color100\Color100.dsw. This workspace should contain three files
The driver program Color100.cpp plots four functions that you will write. You will use the mouse to move between these functions, just like you did in Lab 8.
"Templates" for the four functions you will modify are found in Funky.cpp. These functions receive two constant integers as inputs and return an EzWindows color. The driver function will divide the screen into 100 squares, 10 on each side. These squares will be addressed by their x and y co-ordinates, integers from zero to nine. Your program will be called with each of the 100 possible co-ordinate pairs and will be expected to return a color for the corresponding squares. Examine Funky.cpp and then build and execute Color100 to learn a bit more about the process.
| 0 | Returns Red, if x > y;
White, if x equals y; and
Blue, if x < y
|
| 1 | Returns values that cause the window to resemble the flag of Ireland (three vertical stripes: green, white, and red) or any other European country. |
| 2 | Returns values that cause the window to resemble the flag of the state of North Carolina, but without the seal. |
| 3 | Returns values that cause the window to resemble the flag of the United States, but without the stars. |
Open the workspace c:\files\Lab09\Char104\Char104.dsw. The driver program Char104.cpp displays the results of three procedures you will write. These procedures, or functions, are invoked with a single const input variable, which is a character, and with two reference variables, these specify the EzWindows background and foreground colors. Your program will examine its character input and use it to set the background and foreground colors by changing the reference parameters.
Go ahead and look at Funky.cpp to
see how these functions should look. The function
MyFunc0 sets the foreground to blue for characters
corresponding to digits and to yellow for all other characters. The
background is set to green for vowels and to red for non-vowels.
Build and execute the project to see it run.
| 0 | Sets the background to blue for all characters. Sets the foreground to red for characters that are hexadecimal digits and to blue for all other characters. |
| 1 | Sets the background to black for all letters in your last name and to white for all other characters. Sets the foreground to green for all letters in your first name and to red for all other characters. |
| 2 | Sets the foreground to black for all characters. Sets the background so that each of the colors red, green, blue, and yellow appears at least nineteen times. |