Please send questions to
st10@humboldt.edu .
[st10@nrs-labs 131lab08-8am]$ funct_play2
----------------------------------------------
Welcome to the 10-14-10 version of funct_play2!
----------------------------------------------
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: circ_area
***** DESIGN RECIPE STEP 2.1: *****
Enter the signature comment for the function circ_area, using format:
circ_area : parameter_type parameter_type ... -> return_type
signature: circ_area : double -> double
[st10@nrs-labs 131lab08-8am]$ funct_play2
----------------------------------------------
Welcome to the 10-14-10 version of funct_play2!
----------------------------------------------
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: circ_area
***** DESIGN RECIPE STEP 2.1: *****
Enter the signature comment for the function circ_area, using format:
circ_area : parameter_type parameter_type ... -> return_type
signature: circ_area : double -> double
Your signature for circ_area is:
--------------------------------------------------------
signature: circ_area : double -> double
--------------------------------------------------------
***** DESIGN RECIPE STEP 2.2: *****
Enter a purpose statement for the function circ_area,
"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 the radius of a circle and produces
that circle's area
q
Purpose statement:
---------------------------------------------------------------
purpose: expects the radius of a circle and produces
that circle's area
---------------------------------------------------------------
***** DESIGN RECIPE STEP 2.3: *****
Enter the header for the function, using the format:
return_type circ_area (param_type param_name, ...)
Function header:
double circ_area(double radius)
Your header for circ_area is:
-------------------------------------------------
double circ_area(double radius)
-------------------------------------------------
***** DESIGN RECIPE STEP 3: *****
Enter at least one example call of function circ_area
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: circ_area(0) == 0
abs(circ_area(10) - 314.159) < 0.001
q
Examples:
---------------------------------------------------------------
Examples: circ_area(0) == 0
abs(circ_area(10) - 314.159) < 0.001
---------------------------------------------------------------
BEFORE you type in circ_area's body --- are there any
NEW named constants that you want to CREATE?
(answer y or n):
your reply: y
type in your new named constant declaration, using the format:
const const_type CONST_NAME = expression;
new declaration:
const double PI = 3.14159;
do you have another named constant declaration?
(enter y or n):
your reply: n
NOTE --- if a named constant was already declared for an
OLD function that circ_area calls, then it SHOULD be
visible for use in circ_area, too...
(at least, it should be the way that funct_play2 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 circ_area (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 circ_area's body is complete):
Enter body following the header:
double circ_area(double radius)
{
return PI * radius * radius;
}
q
circ_area's body:
----------------------------------------------------------------
{
return PI * radius * radius;
}
----------------------------------------------------------------
COMPILING circ_area.cpp...
-----------------------------------------------------------------
circ_area.cpp COMPILED! 8-)
Would you like to run circ_area_ck_expect?
(type y if so, n if not)
your answer: y
testing circ_area: true's should mean passed:
---------------------------------------
(circ_area(0) == 0): true
(abs(circ_area(10) - 314.159) < 0.001): true
Enter a C++ expression involving:
circ_area
...and type enter
(or type q to quit):
q
Quitting funct_play2 ... goodbye.
[st10@nrs-labs 131lab08-8am]$ ls
circ_area_ck_expect circ_area.cpp circ_area.o try_expr1.cpp
circ_area_ck_expect.cpp circ_area.h try_expr1 try_expr2.cpp
[st10@nrs-labs 131lab08-8am]$ circ_area_ck_expect
testing circ_area: true's should mean passed:
---------------------------------------
(circ_area(0) == 0): true
(abs(circ_area(10) - 314.159) < 0.001): true
[st10@nrs-labs 131lab08-8am]$ ls
circ_area_ck_expect circ_area.cpp circ_area.o try_expr1.cpp
circ_area_ck_expect.cpp circ_area.h try_expr1 try_expr2.cpp
[st10@nrs-labs 131lab08-8am]$ nano circ_area.cpp
[st10@nrs-labs 131lab08-8am]$ funct_compile
----------------------------------------------
Welcome to the 03-03-10 version of funct_compile!
----------------------------------------------
Are there any already-created C++ functions OR CLASSES (in the current
working directory) which the function to be compiled uses?
(type y if so, n if not)
your answer: n
What is the name of your function?
(note: this script assumes this function is in a file in
the current working directory named after the function
and ending with .cpp)
function name: circ_area
COMPILING circ_area.cpp...
-----------------------------------------------------------------
circ_area.cpp COMPILED! 8-)
trying to compile circ_area_ck_expect.cpp...
Would you like to run circ_area_ck_expect?
(type y if so, n if not)
your answer: y
testing circ_area: true's should mean passed:
---------------------------------------
(circ_area(0) == 0): true
(abs(circ_area(10) - 314.159) < 0.001): true
Enter a C++ expression involving:
circ_area
...and type enter
(or type q to quit):
q
Quitting funct_compile ... goodbye.
[st10@nrs-labs 131lab08-8am]$ nano circ_area.h
[st10@nrs-labs 131lab08-8am]$ nano circ_area_ck_expect.cpp
[st10@nrs-labs 131lab08-8am]$ funct_compile
----------------------------------------------
Welcome to the 03-03-10 version of funct_compile!
----------------------------------------------
Are there any already-created C++ functions OR CLASSES (in the current
working directory) which the function to be compiled uses?
(type y if so, n if not)
your answer: n
What is the name of your function?
(note: this script assumes this function is in a file in
the current working directory named after the function
and ending with .cpp)
function name: circ_area
COMPILING circ_area.cpp...
-----------------------------------------------------------------
circ_area.cpp COMPILED! 8-)
trying to compile circ_area_ck_expect.cpp...
Would you like to run circ_area_ck_expect?
(type y if so, n if not)
your answer: y
testing circ_area: true's should mean passed:
---------------------------------------
(circ_area(0) == 0): true
(abs(circ_area(10) - 314.159) < 0.001): true
Enter a C++ expression involving:
circ_area
...and type enter
(or type q to quit):
q
Quitting funct_compile ... goodbye.
[st10@nrs-labs 131lab08-8am]$ expr_play
----------------------------------------------
Welcome to the 03-03-10 version of expr_play!
----------------------------------------------
Are there any already-created C++ functions (in the current
working directory) which you would like to be able to use
within C++ expressions?
(type y if so, n if not)
your answer: y
*********************************************************
NOTE: to test a function A, you need to give the names
of ALL functions that A uses, as well as those that
THEY use --- otherwise, the tests will fail.
(that is, you may have to give all functions in the
PROGRAM...)
**********************************************************
Enter the name of an already-created function (created in the
current directory), or q to quit:
function name: circ_area
Enter the next name of an already-created function (created
in the current directory), or q to quit:
function name: q
Enter a C++ expression involving:
circ_area
...and type enter
(or type q to quit):
circ_area(10)
value of circ_area(10):
314.159
Enter next C++ expression and type enter
(or type q to quit):
circ_area(10) - 314.159
value of circ_area(10) - 314.159:
0
Enter next C++ expression and type enter
(or type q to quit):
circ_area(10) == 315.159
value of circ_area(10) == 315.159:
false
Enter next C++ expression and type enter
(or type q to quit):
circ_area(10) == 314.159
value of circ_area(10) == 314.159:
true
Enter next C++ expression and type enter
(or type q to quit):
q
Quitting expr_play ... goodbye.
[st10@nrs-labs 131lab08-8am]$ emacs circ_area.h
[st10@nrs-labs 131lab08-8am]$ funct_compile
----------------------------------------------
Welcome to the 03-03-10 version of funct_compile!
----------------------------------------------
Are there any already-created C++ functions OR CLASSES (in the current
working directory) which the function to be compiled uses?
(type y if so, n if not)
your answer: n
What is the name of your function?
(note: this script assumes this function is in a file in
the current working directory named after the function
and ending with .cpp)
function name: circ_area
COMPILING circ_area.cpp...
-----------------------------------------------------------------
circ_area.h:13: error: expected ‘,’ or ‘;’ before ‘double’
---------------------------------------------------------
circ_area.cpp DIDN'T compile! 8-(
(above are the C++ compiler's error messages...)
edit circ_area.cpp and then try funct_compile again...
[st10@nrs-labs 131lab08-8am]$ nano circ_area.h
[st10@nrs-labs 131lab08-8am]$ funct_play2
----------------------------------------------
Welcome to the 10-14-10 version of funct_play2!
----------------------------------------------
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): y
What is the name of your function?
(note: this script assumes this function is in a file in
the current working directory named after the function
and ending with .cpp)
function name: circ_area
what is your preferred text editor? nano
Do you want to edit circ_area.h?
(please enter y or n): y
Proceeding with funct_play2 ... type anything followed by
enter to continue: f
COMPILING circ_area.cpp...
-----------------------------------------------------------------
circ_area.cpp COMPILED! 8-)
Would you like to run circ_area_ck_expect?
(type y if so, n if not)
your answer: y
testing circ_area: true's should mean passed:
---------------------------------------
(circ_area(0) == 0): true
(abs(circ_area(10) - 314.159) < 0.001): true
Enter a C++ expression involving:
circ_area
...and type enter
(or type q to quit):
q
Quitting funct_play2 ... goodbye.
[st10@nrs-labs 131lab08-8am]$ funct_play2
----------------------------------------------
Welcome to the 10-14-10 version of funct_play2!
----------------------------------------------
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: is_safe
***** DESIGN RECIPE STEP 2.1: *****
Enter the signature comment for the function is_safe, using format:
is_safe : parameter_type parameter_type ... -> return_type
signature: is_safe : int -> bool
Your signature for is_safe is:
--------------------------------------------------------
signature: is_safe : int -> bool
--------------------------------------------------------
***** DESIGN RECIPE STEP 2.2: *****
Enter a purpose statement for the function is_safe,
"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 temperature, and produces whether it is less than
the maximum safe temperature of 100 degrees Fahrenheit
q
Purpose statement:
---------------------------------------------------------------
purpose: expects a temperature, and produces whether it is less than
the maximum safe temperature of 100 degrees Fahrenheit
---------------------------------------------------------------
***** DESIGN RECIPE STEP 2.3: *****
Enter the header for the function, using the format:
return_type is_safe (param_type param_name, ...)
Function header:
bool is_safe(int temp)
Your header for is_safe is:
-------------------------------------------------
bool is_safe(int temp)
-------------------------------------------------
***** DESIGN RECIPE STEP 3: *****
Enter at least one example call of function is_safe
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: is_safe(90) == true
is_safe(100) == false
is_safe(150) == false
q
Examples:
---------------------------------------------------------------
Examples: is_safe(90) == true
is_safe(100) == false
is_safe(150) == false
---------------------------------------------------------------
BEFORE you type in is_safe's body --- are there any
NEW named constants that you want to CREATE?
(answer y or n):
your reply: y
type in your new named constant declaration, using the format:
const const_type CONST_NAME = expression;
new declaration:
const int MAX_TEMP = 100;
do you have another named constant declaration?
(enter y or n):
your reply: n
NOTE --- if a named constant was already declared for an
OLD function that is_safe calls, then it SHOULD be
visible for use in is_safe, too...
(at least, it should be the way that funct_play2 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 is_safe (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 is_safe's body is complete):
Enter body following the header:
bool is_safe(int temp)
{
return temp < MAC_TEMP;
}
q
is_safe's body:
----------------------------------------------------------------
{
return temp < MAC_TEMP;
}
----------------------------------------------------------------
COMPILING is_safe.cpp...
-----------------------------------------------------------------
is_safe.cpp: In function ‘bool is_safe(int)’:
is_safe.cpp:22: error: ‘MAC_TEMP’ was not declared in this scope
---------------------------------------------------------
is_safe.cpp DIDN'T compile! 8-(
(above are the C++ compiler's error messages...)
edit is_safe.cpp and then try funct_play2 again,
(or call funct_play2 again, and tell it function DOES
already have a file in the current directory...)
[st10@nrs-labs 131lab08-8am]$ nano is_safe.cpp
[st10@nrs-labs 131lab08-8am]$ funct_compile
----------------------------------------------
Welcome to the 03-03-10 version of funct_compile!
----------------------------------------------
Are there any already-created C++ functions OR CLASSES (in the current
working directory) which the function to be compiled uses?
(type y if so, n if not)
your answer: n
What is the name of your function?
(note: this script assumes this function is in a file in
the current working directory named after the function
and ending with .cpp)
function name: is_safe
COMPILING is_safe.cpp...
-----------------------------------------------------------------
is_safe.cpp COMPILED! 8-)
trying to compile is_safe_ck_expect.cpp...
Would you like to run is_safe_ck_expect?
(type y if so, n if not)
your answer: y
testing is_safe: true's should mean passed:
---------------------------------------
(is_safe(90) == true): true
(is_safe(100) == false): true
(is_safe(150) == false): true
Enter a C++ expression involving:
is_safe
...and type enter
(or type q to quit):
q
Quitting funct_compile ... goodbye.
[st10@nrs-labs 131lab08-8am]$ funct_play2
----------------------------------------------
Welcome to the 10-14-10 version of funct_play2!
----------------------------------------------
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 and last name, and produces the length
of the whole name (how many characters are in both parts)
q
Purpose statement:
---------------------------------------------------------------
purpose: expects a first and last name, and produces the length
of the whole name (how many characters are in both parts)
---------------------------------------------------------------
***** 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("Joe", "Smith") == 8
q
Examples:
---------------------------------------------------------------
Examples: name_length("Joe", "Smith") == 8
---------------------------------------------------------------
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_play2 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("Joe", "Smith") == 8): true
Enter a C++ expression involving:
name_length
...and type enter
(or type q to quit):
name_length("Sharon", "Smith")
value of 11:
11
Enter next C++ expression and type enter
(or type q to quit):
q
Quitting funct_play2 ... goodbye.
[st10@nrs-labs 131lab08-8am]$ ~st10/131submit
*** WELCOME to the 08-26-10 version of the 131 Homework Submission Tool! ***
Which homework is this? (enter the homework number: 1, 2, etc.): 81
Do you simply want to submit all
.rkt, .cpp, and .h files
in the current working directory? (y or n)
your answer: y
ls: *.rkt: No such file or directory
---------------------------------------------
you have asked to submit the following files:
----------------------------------------------
circ_area_ck_expect.cpp
circ_area.cpp
circ_area.h
is_safe_ck_expect.cpp
is_safe.cpp
is_safe.h
name_length_ck_expect.cpp
name_length.cpp
name_length.h
try_expr1.cpp
try_expr2.cpp
try_expr3.cpp
try_expr4.cpp
*---------------------------*
files SHOULD now be submitted;
*---------------------------*
retain st10_hw81_oct15_09-50.tar.gz (now in submitted subdirectory)
as your "receipt" of submission
(You can use ~st10/unziptar_all to create an unzipped/untarred
directory containing copies of your submitted files, if you
would like to look for them...)
*** Goodbye from the 131 Homework Submission Tool ***
[st10@nrs-labs 131lab08-8am]$