void Screen::DrawRectangle(int row, int col, int height, int width) // precondition: screen is blank/all white, // 0 <= row < Size() and 0 <= col < Size(), // 0 < height, and 0 < width { int lastCol = col + width - 1; int lastRow = row + height - 1; int k; if (lastCol >= Size()) { lastCol = Size() - 1; } if (lastRow >= Size()) { lastRow = Size() - 1; } for(k=col; k <= lastCol; k++) // top row { myPixels[row][k] = black; } if (row + height - 1 < Size()) // is bottom row on screen? { for(k=col; k <= lastCol; k++) // bottom row { myPixels[lastRow][k] = black; } } for(k=row; k <= lastRow; k++) // left column { myPixels[k][col] = black; } if (col + width - 1 < Size()) // is right col on screen? { for(k=row; k <= lastRow; k++) // right column { myPixels[k][lastCol] = black; } } }