Please send questions to
st10@humboldt.edu .
[st10@nrs-labs 131lab08-10am]$ 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):
circ_area(7)
value of circ_area(7):
153.938
Enter next C++ expression and type enter
(or type q to quit):
circ_area(34.5)
value of circ_area(34.5):
3739.28
Enter next C++ expression and type enter
(or type q to quit):
q
Quitting funct_play2 ... goodbye.
[st10@nrs-labs 131lab08-10am]$ ls
circ_area_ck_expect circ_area.h try_expr1.cpp
circ_area_ck_expect.cpp circ_area.o try_expr2
circ_area.cpp try_expr1 try_expr2.cpp
[st10@nrs-labs 131lab08-10am]$ nano circ_area.cpp
[st10@nrs-labs 131lab08-10am]$ 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-10am]$ ls
circ_area_ck_expect circ_area.h try_expr1.cpp
circ_area_ck_expect.cpp circ_area.o try_expr2
circ_area.cpp try_expr1 try_expr2.cpp
[st10@nrs-labs 131lab08-10am]$ nano circ_area.h
[st10@nrs-labs 131lab08-10am]$ 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-10am]$ nano circ_area.h
[st10@nrs-labs 131lab08-10am]$ nano circ_area.h
[st10@nrs-labs 131lab08-10am]$ 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-10am]$ ls
circ_area_ck_expect circ_area.h try_expr1.cpp
circ_area_ck_expect.cpp circ_area.o try_expr2
circ_area.cpp try_expr1 try_expr2.cpp
[st10@nrs-labs 131lab08-10am]$ nano circ_area_ck_expect.cpp
[st10@nrs-labs 131lab08-10am]$ 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 in Fahrenheit, and produces
whether it is less than the maximum safe temperature
of 100 degrees Fahrenheit
q
Purpose statement:
---------------------------------------------------------------
purpose: expects a temperature in Fahrenheit, 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 temperature)
Your header for is_safe is:
-------------------------------------------------
bool is_safe(int temperature)
-------------------------------------------------
***** 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(133) == false
q
Examples:
---------------------------------------------------------------
Examples: is_safe(90) == true
is_safe(100) == false
is_safe(133) == 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 MIN_UNSAFE = 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 temperature)
{
return temperature < MIN_UNSAFE;
}
q
is_safe's body:
----------------------------------------------------------------
{
return temperature < MIN_UNSAFE;
}
----------------------------------------------------------------
COMPILING is_safe.cpp...
-----------------------------------------------------------------
is_safe.cpp COMPILED! 8-)
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(133) == false): true
Enter a C++ expression involving:
is_safe
...and type enter
(or type q to quit):
is_safe(45)
value of is_safe(45):
true
Enter next C++ expression and type enter
(or type q to quit):
is_safe(3 + 45)
value of is_safe(3 + 45):
true
Enter next C++ expression and type enter
(or type q to quit):
q
Quitting funct_play2 ... goodbye.
[st10@nrs-labs 131lab08-10am]$ nano is_safe.cpp
[st10@nrs-labs 131lab08-10am]$ ls
circ_area_ck_expect circ_area.o is_safe.h try_expr2
circ_area_ck_expect.cpp is_safe_ck_expect is_safe.o try_expr2.cpp
circ_area.cpp is_safe_ck_expect.cpp try_expr1
circ_area.h is_safe.cpp try_expr1.cpp
[st10@nrs-labs 131lab08-10am]$ 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(133) == 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-10am]$ 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: is_safe
what is your preferred text editor? nano
Do you want to edit is_safe.h?
(please enter y or n): y
Proceeding with funct_play2 ... type anything followed by
enter to continue: d
COMPILING is_safe.cpp...
-----------------------------------------------------------------
is_safe.cpp COMPILED! 8-)
Would you like to run is_safe_ck_expect?
(type y if so, n if not)
your answer: q
please respond with y or n: n
Enter a C++ expression involving:
is_safe
...and type enter
(or type q to quit):
q
Quitting funct_play2 ... goodbye.
[st10@nrs-labs 131lab08-10am]$ 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 name and a last name, and produces
the length of the whole name (the number of characters
in both names combined)
q
Purpose statement:
---------------------------------------------------------------
purpose: expects a first name and a last name, and produces
the length of the whole name (the number of characters
in both names 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("Ann", "Burroughs") == 12
name_length("Hi'there", "Y'all") == 13
q
Examples:
---------------------------------------------------------------
Examples: name_length("Ann", "Burroughs") == 12
name_length("Hi'there", "Y'all") == 13
---------------------------------------------------------------
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("Ann", "Burroughs") == 12): true
(name_length("Hi'there", "Y'all") == 13): true
Enter a C++ expression involving:
name_length
...and type enter
(or type q to quit):
name_length("\"", "Jones")
value of 6:
6
Enter next C++ expression and type enter
(or type q to quit):
name_length("Wendy", "Black")
value of 10:
10
Enter next C++ expression and type enter
(or type q to quit):
q
Quitting funct_play2 ... goodbye.
[st10@nrs-labs 131lab08-10am]$ ~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
*---------------------------*
files SHOULD now be submitted;
*---------------------------*
retain st10_hw81_oct15_11-44.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-10am]$