Lab date: Wednesday October 11th. Assignment due by 2pm Friday, October 13th. These directions were posted Monday evening, October 9th.
The goal of Lab 2 was for you to display one (or more) gifs or jpegs with various distortions, by using C++ to compute various widths and heights using the type of arithmetic expressions described in Chapter 2 of Friedman and Koffman.
Sections 3.4 and 3.5 of your text explain how you can design your own functions, both with and without arguments. You are to rework your Lab 2 so that the strings are generated by calls to functions that you define yourself. There are numerous ways to do this, as explained below.
Some general guidelines:
First, define two functions int width(int) and int height(n) which, when given a integer n, return the appropriate width and height, in the same way that you computed them in Lab 2. Then define a function void imgString(int, int) that takes two arguments, one for the image width and the other for the height and prints out the correct <img ....> </img> tag, basically the same output that you produced in Lab 2. This function should be given as input arguments a call to your width and height functions, with the appropriate n values. Thus, a call to your function would appear as:
imgString(width(0),height(0));
An alternative approach would be to define imgString(int) that would take only the parameter n and then would call the width and height functions internally.
To help you out, here's the key part of a height function that would produce a height of 261 (for the Yeti dog picture) for n=0 and n=2 and a height of 200 for n=1. You can build a similar one for the width.
(n - 1)*(n - 1)*61 + 200
More advanced possibilities (not part of the required assignment): Use a struct or class to hold the dimensions and file name. Define a member function that produces the string. Write output to a file instead of to the console. Use a string argument to pass through the gif or jpeg file name.
Here are the sample images again that you're welcome to use for your work: