# CSCI 201 Lab 12 -- Arrays in C++

Yep, we know that arrays are covered in chapter 10 of the textbook and you aren't there yet in the lectures, but the semester is drawing to a close....

This lab is Lab 4 but with arrays.

If a directory called C:\FILES\Lab12 presently exists on your computer, delete it.

Download a ZIP'ed copy of the Lab 12 project and store it in the C:\FILES directory.

Go into the MS-DOS prompt and execute the following commands:

• cd c:\files
• mkdir Lab12
• cd Lab12
• pkunzip  -d  ..\lab12.zip

Build and the project and run the project. You should see a familar face. However, notice that this time the face has a nose that isn't an equalateral triangle and the eye has six points. Something exciting is happending.

## Arrays

Study this lab's C++ program, Face.cpp. The following line of C++ code: ``` Position FaceShape[4] = { Position( 1.0f, 1.0f) , Position(11.0f, 1.0f) , Position(11.0f, 15.0f) , Position( 1.0f, 15.0f) } ; ``` declares and then initializes an array of four `Position`s. These four `Position`s are a polygon outlining the head of the face. The next line of code: ``` MyWin.RenderPolygon(FaceShape, 4, Yellow, true); ``` draws the four point polygon and fills it with yellow. The final argument (`true`) to `RenderPolygon` specifies that a black border should be trace around the edge of the polygon.

If you look a big further through the code, you'll see where the 3-point nose, the 4-point mouth, and the 6-point eye are drawn.

Your job is to improve the face to resemble the model. We have three checkoffs in this lab. It is OK to skip an instructor checkoff as long as you show the instructor your final result.

### Lab checkoff I

Narrow the chin a bit. This will involve modifying the `FaceShape` array to have six points.

### Lab checkoff II

Add that little shadow under the nose. Don't create a new array to do this. Instead, after you've drawn the red nose, modify the second element of `NoseShape` with the statement ``` NoseShape[2] = Position( 6.0f, 10.9f) ; ``` and then redraw the polygon in black.

### Lab checkoff III

Add the left eye. Again don't create a new array. You can move each point of the `EyeShape` array to the right position with the statement ``` EyeShape[i].SetXDistance(EyeShape[i].GetXDistance()+4.0f) ; ``` All you need to do is write a `for` loop around the above to execute the statement for all values of `i` from 0 to 5.