[st10@nrs-labs lab8]$ funct_play
----------------------------------------------
Welcome to the 2016-10-13 version of funct_play!
----------------------------------------------
Are there any already-created C++ functions (in the current
working directory) which you would like to be able to use
within your new function?
(type y if so, n if not)
your answer: n
Is your new function already in a file in the local directory?
(answer y or n): n
--- Entering a new function ---
Enter the name for your new function:
Function name: name_length
***** DESIGN RECIPE STEP 2.1: *****
Enter the signature comment for the function name_length, using format:
name_length : parameter_type parameter_type ... -> return_type
signature: name_length : string string -> int
Your signature for name_length is:
--------------------------------------------------------
signature: name_length : string string -> int
--------------------------------------------------------
***** DESIGN RECIPE STEP 2.2: *****
Enter a purpose statement for the function name_length,
"a brief comment of what the function is to compute" [HtDP,
p. 18]
(enter a line containing NOTHING but q and typing the Enter key
to show when your purpose statement is complete):
purpose: expects a first name and a last name,
and returns the number of characters in both
combined
q
Purpose statement:
---------------------------------------------------------------
purpose: expects a first name and a last name,
and returns the number of characters in both
combined
---------------------------------------------------------------
***** DESIGN RECIPE STEP 2.3: *****
Enter the header for the function, using the format:
return_type name_length (param_type param_name, ...)
Function header:
int name_length(string first_name, string last_name)
Your header for name_length is:
-------------------------------------------------
int name_length(string first_name, string last_name)
-------------------------------------------------
***** DESIGN RECIPE STEP 3: *****
Enter at least one example call of function name_length
including input(s) and the expected output given those
input(s); for example,
my_funct(3, 4) == 12
my_funct(0, 0) == -3
(enter a line containing NOTHING but q and typing the Enter key
to show when you have entered all of your examples):
Examples: name_length("Justin", "Savage") == 12
name_length("Sharon", "Williams") == 14
q
Examples:
---------------------------------------------------------------
examples: name_length("Justin", "Savage") == 12
name_length("Sharon", "Williams") == 14
---------------------------------------------------------------
BEFORE you type in name_length's body --- are there any
NEW named constants that you want to CREATE?
(answer y or n):
your reply: n
NOTE --- if a named constant was already declared for an
OLD function that name_length calls, then it SHOULD be
visible for use in name_length, too...
(at least, it should be the way that funct_play sets these up ---
we will discuss SCOPE later, and then perhaps discuss some
other const declaration placement options.
***** DESIGN RECIPE STEPS 4, 5 *****
Enter the template/body of the name_length (the part following the header),
being sure to include the { and } that should enclose it.
(enter a line containing NOTHING but q and typing the Enter key
to show when name_length's body is complete):
Enter body following the header:
int name_length(string first_name, string last_name)
{
return first_name.length() + last_name.length();
}
q
name_length's body:
----------------------------------------------------------------
{
return first_name.length() + last_name.length();
}
----------------------------------------------------------------
COMPILING name_length.cpp...
-----------------------------------------------------------------
name_length.cpp COMPILED! 8-)
Would you like to run name_length_ck_expect?
(type y if so, n if not)
your answer: y
testing name_length: true's should mean passed:
---------------------------------------
(name_length("Justin", "Savage") == 12): true
(name_length("Sharon", "Williams") == 14): true
Enter a C++ expression involving:
name_length
...and type enter
(or type q to quit):
name_length("Moo", "Cow")
value of 6:
6
Enter next C++ expression and type enter
(or type q to quit):
q
Quitting funct_play ... goodbye.
[st10@nrs-labs lab8]$