Please send questions to
st10@humboldt.edu .
****************
ENTER NAMED CONSTANT - DONE
****************
last modified: 12-12-11
The user can declare named constants, and then use them in the body
of their function.
STATUS: DONE
FIRST PASSED: 12-06-11 (they completed earlier, though, I think -- took
me a while to get to completing acceptance test for
this)
acceptance tests last attempted: 12-12-11
acceptance tests last passed: 12-12-11
------------------
acceptance test 1
------------------
user can declare a named constant, and then use it in a function
(make sure that /Users/smtuttle/480xp-tests/const-exs exists, and
is empty -- pre-4 should have emptied it;)
(if necessary:
1. run:
python3 theGui.pyw
2. Click "Change directory" and navigate to the following
directory:
/Users/smtuttle/480xp-tests/const-exs
...and click "Choose".
)
3. Click "New" to create a new function circ_area -- which, wow,
happens to use a named constant!
circ_area
circ_area: double -> double
<make sure this is multiple-lines!!>
expects the radius of a circle, and produces the area
of a circle with that radius
double circ_area(double radius)
const double PI = 3.14159;
circ_area(10) == 314.159
circ_area(1) == 3.14159
{
return PI * (radius * radius);
}
4. Click "Compile, Test and Save";
See if compiles and if all tests pass;
5. See if can now run an expression using this function:
* move windows around so you have the Helper++ window
* now, in Helper++:
* click circ_area's checkbox on the right;
* enter the expression:
circ_area(10)
...and click Execute.
should give result: 314.159
6. See if can now run an expression using this function that happens
to include the named constant
* slightly crueler, but OUGHT to work if implemented
as desired; if this passes, though, it is an indication
that a function using this function (as the expression's
main is) can use such a named constant, too?
enter the expression:
circ_area(PI)
...and click Execute.
should give approximate result 31.0062
LAST TESTED: 12-12-11
LAST PASSED: 12-12-11